﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;

namespace TestDxfDocument
{
    class Milling_cutter
    {
        public static string[] MatchData(string str)
        {
            string p1 = "[A-Z]";
            string p2 = "[0-9.]+";
            string p3 = "(?<=/)[ 0-9.]+";
            var s1 = Regex.Match(str, p1);
            var s2 = Regex.Match(str, p2);
            var s3 = Regex.Match(str, p3);
            return new string[] { s1.Value, s2.Value, s3.Value.Trim() };
        }

        public static void Millingshank(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            //参数
            /*
            var bbxz = 3;
            var d1 = 6.0;
            var d = 6;
            var d2 = 5.087;
            var l1 = 36.0;
            var l2 =32.0;
            var l3 = 10.0;
            var l4 = 26;
            var l5 = 18;
            var h = 4.8;
            var r2 = 1.2;
            var s1 = "B 1.6/ 6.3";*/

            var bbxz = Convert.ToDouble(data["bbxz"]);
            var d1 = Convert.ToDouble(data["dconms"]);
            var d = Convert.ToDouble(data["d"]);
            var d2 = Convert.ToDouble(data["d2"]);
            var l1 = Convert.ToDouble(data["ls"]);
            var l2 = Convert.ToDouble(data["l2"]);
            var l3 = Convert.ToDouble(data["l3"]);
            var l4 = Convert.ToDouble(data["l4"]);
            var l5 = Convert.ToDouble(data["l5"]);
            var h = Convert.ToDouble(data["h"]);
            var r2 = Convert.ToDouble(data["r2"]);
            var s1 = "B 1.6/ 6.3";


            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度

            if (bbxz == 0)
            {

                var v1 = new Vector2(0, 0);
                var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
                var v3p = fun.Polar(v2, 0, l1);
                var v3 = fun.Polar(v3p, pi, 0.1 * d1);
                var v4 = fun.Polar(v3p, -90 * pi / 180, 0.1 * d1);
                var v5 = fun.mirrorpoint(v4, v1, fun.Polar(v1, 0, 1));
                var v6 = fun.mirrorpoint(v3, v1, fun.Polar(v1, 0, 1));
                var v7 = fun.mirrorpoint(v2, v1, fun.Polar(v1, 0, 1));
                var v8 = fun.Polar(v1, 90 * pi / 180, (3.27 / 4.04 * d1) / 2);
                var v9 = fun.mirrorpoint(v8, v1, fun.Polar(v1, 0, 1));
                var v10 = fun.Polar(v8, pi, 0.2 * l1);
                var v11 = fun.Polar(v9, pi, 0.2 * l1);
                var v12 = fun.Polar(v1, pi, 0.2 * l1);
                var v13 = fun.Polar(v1, 0, l1 + 0.05 * l1);
                var v14 = fun.Polar(v12, pi, 0.05 * l1);

                var polyline1 = Pus.AddPointsToLwPolyLine(v2, v3, v4, v5, v6, v7, v2);
                fun.PolyFill(dxf, polyline1, 0.2, contour);
                var line1 = new Line(v3, v6);
                fun.drawBline(dxf, line1, 0.2, contour);
                var line2 = new Line(v10, v8);
                fun.drawBline(dxf, line2, 0.2, contour);
                var line3 = new Line(v11, v9);
                fun.drawBline(dxf, line3, 0.2, contour);
                var polyline2 = Pus.AddPointsToLwPolyLine(v10, v12, v11);
                polyline2.Vertexes[0].Bulge = Math.Tan(90 * Math.PI / 180 / 4);
                polyline2.Vertexes[1].Bulge = Math.Tan(-90 * Math.PI / 180 / 4);
                polyline2.Lineweight = Lineweight.W25;
                polyline2.Layer = additionalline;
                dxf.AddEntity(polyline2);
                var line4 = new Line(v14, v13);
                line4.Layer = centre;
                line4.Lineweight = Lineweight.W25;
                line4.Linetype = Linetype.DashDot;
                dxf.AddEntity(line4);



                Text text1 = new Text(l1 + "", v1, height, 0);
                var l1_ = text1.Value.Length * height * 0.7;
                Text text2 = new Text(d1 + "", v1, height, 0);
                var d1_ = text2.Value.Length * height * 0.7;

                fun.dimrot1(dxf, v7, v5, 180, 10, l1_, height, arrowsize, exline, "LS=" + l1, "", "");
                fun.dimrot1(dxf, v3, v6, -90, 10, d1_, height, arrowsize, exline, "DCONMS=" + d1, "", "");
            }
            if (bbxz == 1)
            {
                var v1 = new Vector2(0, 0);
                var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
                var v3p = fun.Polar(v2, 0, l1);
                var v3 = fun.Polar(v3p, pi, (d1 - h) / 2 * 0.95);
                var v4 = fun.Polar(v3p, -90 * pi / 180, (d1 - h) / 2 * 0.95);
                var v5 = fun.mirrorpoint(v4, v1, fun.Polar(v1, 0, 1));
                var v6 = fun.mirrorpoint(v3, v1, fun.Polar(v1, 0, 1));
                var v7 = fun.mirrorpoint(v2, v1, fun.Polar(v1, 0, 1));
                var v8 = fun.Polar(v1, 90 * pi / 180, (3.27 / 4.04 * d1) / 2);
                var v9 = fun.mirrorpoint(v8, v1, fun.Polar(v1, 0, 1));
                var v10 = fun.Polar(v8, pi, 0.2 * l1);
                var v11 = fun.Polar(v9, pi, 0.2 * l1);
                var v12 = fun.Polar(v1, pi, 0.2 * l1);
                var v13 = fun.Polar(v1, 0, l1 + 0.05 * l1);
                var v14 = fun.Polar(v12, pi, 0.05 * l1);
                var v15 = fun.Polar(v13, 0, 3 * d1);
                var v16 = fun.Polar(v15, 90 * pi / 180, 0.65 * d1);
                var v17 = fun.Polar(v15, -90 * pi / 180, 0.65 * d1);
                var v18 = fun.Polar(v15, pi, 0.65 * d1);
                var v19 = fun.Polar(v15, 0, 0.65 * d1);
                var v20 = new Vector2(v15.X - Math.Sqrt(Math.Pow(d1 / 2.0, 2) - Math.Pow(h - d1 / 2.0, 2)), v15.Y + h - d1 / 2.0);
                var v21 = new Vector2(v15.X + Math.Sqrt(Math.Pow(d1 / 2.0, 2) - Math.Pow(h - d1 / 2.0, 2)), v15.Y + h - d1 / 2.0);
                var v23 = new Vector2(v3p.X - l2 - l3 / 2, v20.Y);
                var v24 = fun.Polar(v23, 0, l3);
                var v22 = fun.Inters(v23, fun.Polar(v23, 135 * pi / 180, 1), v2, v3);
                var v25 = fun.Inters(v24, fun.Polar(v24, 45 * pi / 180, 1), v2, v3);
                var v27 = new Vector2(v3p.X - l4, v24.Y);
                var v26 = fun.Inters(v27, fun.Polar(v27, 135 * pi / 180, 1), v2, v3p);
                var v28 = fun.Inters(v27, fun.Polar(v27, 0, 1), v6, v3);
                var v29 = new Vector2(v5.X, v28.Y);
                var d02 = fun.CalDistance(v4, v5);
                var v30 = new Vector2(v15.X - Math.Sqrt(Math.Pow(d02 / 2, 2) - Math.Pow(h - d1 / 2, 2)), v15.Y + h - d1 / 2);
                var v31 = new Vector2(v15.X + Math.Sqrt(Math.Pow(d02 / 2, 2) - Math.Pow(h - d1 / 2, 2)), v15.Y + h - d1 / 2);
                var v32 = new Vector2(v23.X + (v24.X - v23.X) / 2, v23.Y + (v25.Y - v24.Y) * 2);
                var v33 = fun.mirrorpoint(v32, v12, v13);


                if (d1 >= 6 && d1 <= 20)
                {
                    var polyline1 = Pus.AddPointsToLwPolyLine(v2, v22, v23, v24, v25, v3, v4, v5, v6, v7, v2);
                    fun.PolyFill(dxf, polyline1, 0.2, contour);
                    var line1 = new Line(v3, v6);
                    fun.drawBline(dxf, line1, 0.2, contour);
                    var line2 = new Line(v10, v8);
                    fun.drawBline(dxf, line2, 0.2, contour);
                    var line3 = new Line(v11, v9);
                    fun.drawBline(dxf, line3, 0.2, contour);
                    var polyline2 = Pus.AddPointsToLwPolyLine(v10, v12, v11);
                    polyline2.Vertexes[0].Bulge = Math.Tan(90 * Math.PI / 180 / 4);
                    polyline2.Vertexes[1].Bulge = Math.Tan(-90 * Math.PI / 180 / 4);
                    polyline2.Lineweight = Lineweight.W25;
                    polyline2.Layer = additionalline;
                    dxf.AddEntity(polyline2);
                    var line4 = new Line(v14, v13);
                    line4.Layer = centre;
                    line4.Lineweight = Lineweight.W25;
                    line4.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line4);
                    var line5 = new Line(v18, v19);
                    line5.Layer = centre;
                    line5.Lineweight = Lineweight.W25;
                    line5.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line5);
                    var line6 = new Line(v16, v17);
                    line6.Layer = centre;
                    line6.Lineweight = Lineweight.W25;
                    line6.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line6);
                    var line7 = new Line(v32, v33);
                    line7.Layer = centre;
                    line7.Lineweight = Lineweight.W25;
                    line7.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line7);
                    var line8 = new Line(v20, v21);
                    fun.drawBline(dxf, line8, 0.2, contour);
                    var polyline3 = Pus.AddPointsToLwPolyLine(fun.Polar(v15, 0, d1 / 2), fun.Polar(v15, pi, d1 / 2), fun.Polar(v15, 0, d1 / 2));
                    polyline3.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                    polyline3.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                    fun.PolyFill(dxf, polyline3, 0.2, contour);
                    var polyline4 = Pus.AddPointsToLwPolyLine(v20, v21, v20);
                    polyline4.Vertexes[0].Bulge = Math.Tan((360 * pi / 180 - (fun.CalAngle(v15, v20) - fun.CalAngle(v15, v21))) / 4);
                    String[] htype1 = new String[100];
                    Line[] hline1 = new Line[100];
                    Arc[] harc1 = new Arc[100];
                    int hnumst1 = polyline4.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst1; i++)
                    {
                        htype1[i] = polyline4.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype1[i] == "Line")
                        {
                            hline1[i] = (Line)polyline4.Explode()[i];
                        }
                        if (htype1[i] == "Arc")
                        {
                            harc1[i] = (Arc)polyline4.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype1, hnumst1, 45, 4, hline1, harc1, hatching);


                    Text text1 = new Text(l1 + "", v1, height, 0);
                    var l1_ = text1.Value.Length * height * 0.7;
                    Text text2 = new Text(d1 + "", v1, height, 0);
                    var d1_ = text2.Value.Length * height * 0.7;
                    Text text3 = new Text(l2 + "", v1, height, 0);
                    var l2_ = text3.Value.Length * height * 0.7;
                    Text text4 = new Text(l3 + "", v1, height, 0);
                    var l3_ = text4.Value.Length * height * 0.7;
                    Text text6 = new Text(h + "", v1, height, 0);
                    var h_ = text6.Value.Length * height * 0.1;

                    fun.dimrot1(dxf, v26, v6, -90, offset * 1, d1_, height, arrowsize, exline, "DCONMS=" + d1, "   ", "");
                    fun.dimrot1(dxf, v7, v5, 180, offset * 2, l1_, height, arrowsize, exline, "LS=" + l1, "", "");
                    fun.dimrot1(dxf, v33, v5, 0, offset * 3, l2_, height, arrowsize, exline, "l2=" + l2, "  ", "");
                    fun.dimrot1(dxf, v23, v24, 0, offset, l3_, height, arrowsize, exline, "l3=" + l3, "", "");
                    fun.dimrot1(dxf, v21, new Vector2(v15.X, v7.Y), -90, offset, 0, height, arrowsize, exline, "h=" + h, "", "");
                    fun.jdbz2(dxf, new Line(v24, v25), new Line(v24, fun.Polar(v24, 90 * pi / 180, 0.1)), offset * 1.5, height, arrowsize, exline, "45°", "", "");

                }
                if (d1 >= 25 && d1 <= 63)
                {
                    var polyline1 = Pus.AddPointsToLwPolyLine(v2, v22, v23, v24, v25, v26, v27, v29, v5, v6, v7, v2);
                    fun.PolyFill(dxf, polyline1, 0.2, contour);
                    var line1 = new Line(v28, v6);
                    fun.drawBline(dxf, line1, 0.2, contour);
                    var line2 = new Line(v10, v8);
                    fun.drawBline(dxf, line2, 0.2, contour);
                    var line3 = new Line(v11, v9);
                    fun.drawBline(dxf, line3, 0.2, contour);
                    var polyline2 = Pus.AddPointsToLwPolyLine(v10, v12, v11);
                    polyline2.Vertexes[0].Bulge = Math.Tan(90 * Math.PI / 180 / 4);
                    polyline2.Vertexes[1].Bulge = Math.Tan(-90 * Math.PI / 180 / 4);
                    polyline2.Lineweight = Lineweight.W25;
                    polyline2.Layer = additionalline;
                    dxf.AddEntity(polyline2);
                    var line4 = new Line(v14, v13);
                    line4.Layer = centre;
                    line4.Lineweight = Lineweight.W25;
                    line4.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line4);
                    var line5 = new Line(v18, v19);
                    line5.Layer = centre;
                    line5.Lineweight = Lineweight.W25;
                    line5.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line5);
                    var line6 = new Line(v16, v17);
                    line6.Layer = centre;
                    line6.Lineweight = Lineweight.W25;
                    line6.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line6);
                    var line7 = new Line(v32, v33);
                    line7.Layer = centre;
                    line7.Lineweight = Lineweight.W25;
                    line7.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line7);
                    var line8 = new Line(v20, v21);
                    fun.drawBline(dxf, line8, 0.2, contour);
                    var polyline3 = Pus.AddPointsToLwPolyLine(fun.Polar(v15, 0, d1 / 2), fun.Polar(v15, pi, d1 / 2), fun.Polar(v15, 0, d1 / 2));
                    polyline3.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                    polyline3.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                    fun.PolyFill(dxf, polyline3, 0.2, contour);
                    var polyline4 = Pus.AddPointsToLwPolyLine(v20, v21, v20);
                    polyline4.Vertexes[0].Bulge = Math.Tan((360 * pi / 180 - (fun.CalAngle(v15, v20) - fun.CalAngle(v15, v21))) / 4);
                    String[] htype1 = new String[100];
                    Line[] hline1 = new Line[100];
                    Arc[] harc1 = new Arc[100];
                    int hnumst1 = polyline4.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst1; i++)
                    {
                        htype1[i] = polyline4.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype1[i] == "Line")
                        {
                            hline1[i] = (Line)polyline4.Explode()[i];
                        }
                        if (htype1[i] == "Arc")
                        {
                            harc1[i] = (Arc)polyline4.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype1, hnumst1, 45, 4, hline1, harc1, hatching);



                    Text text1 = new Text(l1 + "", v1, height, 0);
                    var l1_ = text1.Value.Length * height * 0.7;
                    Text text2 = new Text(d1 + "", v1, height, 0);
                    var d1_ = text2.Value.Length * height * 0.7;
                    Text text3 = new Text(l2 + "", v1, height, 0);
                    var l2_ = text3.Value.Length * height * 0.7;
                    Text text4 = new Text(l3 + "", v1, height, 0);
                    var l3_ = text4.Value.Length * height * 0.7;
                    Text text5 = new Text(l4 + "", v1, height, 0);
                    var l4_ = text5.Value.Length * height * 0.7;
                    Text text6 = new Text(h + "", v1, height, 0);
                    var h_ = text6.Value.Length * height * 0.7;

                    fun.dimrot1(dxf, v26, v6, -90, offset * 3, d1_, height, arrowsize, exline, "DCONMS=" + d1, "    ", " ");
                    fun.dimrot1(dxf, v7, v5, 180, offset * 2.5, l1_, height, arrowsize, exline, "LS=" + l1, "", "");
                    fun.dimrot1(dxf, v33, v5, 180, offset, l2_, height, arrowsize, exline, "l2=" + l2, "  ", "");
                    fun.dimrot1(dxf, v23, v24, 0, offset, l3_, height, arrowsize, exline, "l3=" + l3, "", "");
                    fun.dimrot1(dxf, v27, v29, 0, offset, l4_, height, arrowsize, exline, "l4=" + l4, "", "");
                    fun.dimrot1(dxf, v21, new Vector2(v15.X, v7.Y), -90, offset * 2.5, h_, height, arrowsize, exline, "h=" + h, "", "");
                    fun.jdbz2(dxf, new Line(v27, fun.Polar(v27, 90 * pi / 180, 0.1)), new Line(v27, v26), offset * 3, height, arrowsize, exline, "45°", "", "");

                }



            }
            if (bbxz == 2)
            {
                var v1 = new Vector2(0, 0);
                var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
                var v3p = fun.Polar(v2, 0, l1);
                var v3 = fun.Polar(v3p, pi, (d1 - h) / 2 * 0.95);
                var v4 = fun.Polar(v3p, -90 * pi / 180, (d1 - h) / 2 * 0.95);
                var v5 = fun.mirrorpoint(v4, v1, fun.Polar(v1, 0, 1));
                var v6 = fun.mirrorpoint(v3, v1, fun.Polar(v1, 0, 1));
                var v7 = fun.mirrorpoint(v2, v1, fun.Polar(v1, 0, 1));
                var v8 = fun.Polar(v1, 90 * pi / 180, (3.27 / 4.04 * d1) / 2);
                var v9 = fun.mirrorpoint(v8, v1, fun.Polar(v1, 0, 1));
                var v10 = fun.Polar(v8, pi, 0.2 * l1);
                var v11 = fun.Polar(v9, pi, 0.2 * l1);
                var v12 = fun.Polar(v1, pi, 0.2 * l1);
                var v13 = fun.Polar(v1, 0, l1 + 0.05 * l1);
                var v14 = fun.Polar(v12, pi, 0.05 * l1);
                var v15 = fun.Polar(v3p, pi, l4);
                var v16 = fun.Inters(v15, fun.Polar(v15, -43 * pi / 180, 1), v3p, fun.Polar(v3p, -178 * pi / 180, 1));
                var v17 = fun.Inters(v3p, fun.Polar(v3p, -178 * pi / 180, 1), v6, fun.Polar(v6, 90 * pi / 180, 1));
                var v18 = fun.Polar(v3p, pi, l5);
                var v19 = fun.Polar(v18, 90 * pi / 180, d1 / 4);
                var v20 = fun.mirrorpoint(v19, v1, fun.Polar(v1, 0, 1));
                var v21 = fun.Polar(v13, 0, 3 * d1);
                var v22 = fun.Polar(v21, 90 * pi / 180, 0.65 * d1);
                var v23 = fun.Polar(v21, -90 * pi / 180, 0.65 * d1);
                var v24 = fun.Polar(v21, pi, 0.65 * d1);
                var v25 = fun.Polar(v21, 0, 0.65 * d1);
                var v26 = new Vector2(v21.X - Math.Sqrt(Math.Pow(d1 / 2, 2) - Math.Pow(h - d1 / 2, 2)), v21.Y + h - d1 / 2);
                var v27 = new Vector2(v21.X + Math.Sqrt(Math.Pow(d1 / 2, 2) - Math.Pow(h - d1 / 2, 2)), v21.Y + h - d1 / 2);

                var polyline1 = Pus.AddPointsToLwPolyLine(v2, v15, v16, v3p, v5, v6, v7, v2);
                var polyline2 = Pus.Fillet4LwPline(polyline1, 2, r2);
                fun.PolyFill(dxf, polyline2, 0.2, contour);
                var line1 = new Line(v6, v17);
                fun.drawBline(dxf, line1, 0.2, contour);
                var line2 = new Line(v8, v10);
                fun.drawBline(dxf, line2, 0.2, contour);
                var line3 = new Line(v9, v11);
                fun.drawBline(dxf, line3, 0.2, contour);
                var line4 = new Line(v14, v13);
                line4.Layer = centre;
                line4.Lineweight = Lineweight.W25;
                line4.Linetype = Linetype.DashDot;
                dxf.AddEntity(line4);
                var line5 = new Line(v19, v20);
                line5.Layer = centre;
                line5.Lineweight = Lineweight.W25;
                line5.Linetype = Linetype.DashDot;
                dxf.AddEntity(line5);
                var line6 = new Line(v24, v25);
                line6.Layer = centre;
                line6.Lineweight = Lineweight.W25;
                line6.Linetype = Linetype.DashDot;
                dxf.AddEntity(line6);
                var line7 = new Line(v22, v23);
                line7.Layer = centre;
                line7.Lineweight = Lineweight.W25;
                line7.Linetype = Linetype.DashDot;
                dxf.AddEntity(line7);
                var polyline3 = Pus.AddPointsToLwPolyLine(v26, v27, v26);
                polyline3.Vertexes[0].Bulge = Math.Tan((360 * pi / 180 - (fun.CalAngle(v21, v26) - fun.CalAngle(v21, v27))) / 4);
                fun.PolyFill(dxf, polyline3, 0.2, contour);
                var polyline4 = Pus.AddPointsToLwPolyLine(v10, v12, v11);
                polyline4.Vertexes[0].Bulge = Math.Tan(90 * Math.PI / 180 / 4);
                polyline4.Vertexes[1].Bulge = Math.Tan(-90 * Math.PI / 180 / 4);
                polyline4.Lineweight = Lineweight.W25;
                polyline4.Layer = additionalline;
                dxf.AddEntity(polyline4);
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = polyline3.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = polyline3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)polyline3.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)polyline3.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 4, hline1, harc1, hatching);



                Text text1 = new Text(l1 + "", v1, height, 0);
                var l1_ = text1.Value.Length * height * 0.7;
                Text text2 = new Text(d1 + "", v1, height, 0);
                var d1_ = text2.Value.Length * height * 0.7;
                Text text3 = new Text(l2 + "", v1, height, 0);
                var l4_ = text3.Value.Length * height * 0.7;
                Text text4 = new Text(l4 + "", v1, height, 0);
                var l5_ = text4.Value.Length * height * 0.7;
                Text text6 = new Text(h + "", v1, height, 0);
                var h_ = text6.Value.Length * height * 0.7;

                fun.dimrot1(dxf, fun.Polar(v21, pi, d1 / 2), fun.Polar(v21, 0, d1 / 2), 180, d1 * 2, d1_, height, arrowsize, exline, "DCONMS=" + d1, "    ", " ");
                fun.dimrot1(dxf, v2, v3p, 0, offset * 3, l1_, height, arrowsize, exline, "LS=" + l1, "", "");
                fun.dimrot1(dxf, v15, v3p, 0, offset * 2, l4_, height, arrowsize, exline, "l4=" + l4, " ", "");
                fun.dimrot1(dxf, v19, v3p, 0, offset, l5_, height, arrowsize, exline, "l5=" + l5, "", "");
                fun.dimrot1(dxf, v27, fun.Polar(v21, -90 * pi / 180, d1 / 2), -90, d1 * 2, h_ * 0.1, height, arrowsize, exline, "h=" + h, "", "h13");
                fun.jdbz2(dxf, new Line(v15, fun.Polar(v15, (90 + 47) * pi / 180, 0.1)), new Line(v15, fun.Polar(v15, 90 * pi / 180, 0.1)), offset, height, arrowsize, exline, "47°", " ", "");
                fun.jdbz2(dxf, new Line(v3p, fun.Polar(v3p, (180 + 2) * pi / 180, 0.1)), new Line(v3p, fun.Polar(v3p, 180 * pi / 180, 0.1)), offset, height / 2, arrowsize, 0.5, "2°", "  ", "");
                var arc = Pus.GetArcFromPline(polyline2, 1);
                var arc2Cen = Pus.ToV2(arc.Center);
                fun.jt1(dxf, fun.Polar(arc2Cen, -133 * pi / 180, r2), 47, r2 * 3, 1, "r2", height);



            }
            if (bbxz == 3)
            {
                var v1 = new Vector2(0, 0);
                var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
                var v3p = fun.Polar(v2, 0, l1);
                var v3 = fun.Polar(v3p, pi, 0.1 * d1);
                var v4 = fun.Polar(v3p, -90 * pi / 180, 0.1 * d1);
                var v5 = fun.mirrorpoint(v4, v1, fun.Polar(v1, 0, 1));
                var v6 = fun.mirrorpoint(v3, v1, fun.Polar(v1, 0, 1));
                var v7 = fun.mirrorpoint(v2, v1, fun.Polar(v1, 0, 1));
                var v8 = fun.Polar(v1, 90 * pi / 180, (3.27 / 4.04 * d1) / 2);
                var v9 = fun.mirrorpoint(v8, v1, fun.Polar(v1, 0, 1));
                var v10 = fun.Polar(v8, pi, 0.2 * l1);
                var v11 = fun.Polar(v9, pi, 0.2 * l1);
                var v12 = fun.Polar(v1, pi, 0.2 * l1);
                var v13 = fun.Polar(v1, 0, l1 + 0.05 * l1);
                var v14 = fun.Polar(v12, pi, 0.05 * l1);
                var v15 = fun.Polar(v2, 0, (l1 - l3));
                var v16 = fun.Polar(v15, -90 * pi / 180, (d1 - d) / 2);
                var v18p = fun.Polar(v16, 0, l3);
                var v18 = fun.Polar(v18p, pi, (d1 - h) / 2 * 0.95);
                var v19 = fun.Polar(v18p, -90 * pi / 180, (d1 - h) / 2 * 0.95);
                var v17 = new Vector2(v16.X, v19.Y);
                var v20 = fun.mirrorpoint(v15, v1, fun.Polar(v1, 0, 1));
                var v21 = fun.mirrorpoint(v16, v1, fun.Polar(v1, 0, 1));
                var v22 = fun.mirrorpoint(v17, v1, fun.Polar(v1, 0, 1));
                var v23 = fun.mirrorpoint(v18, v1, fun.Polar(v1, 0, 1));
                var v24 = fun.mirrorpoint(v19, v1, fun.Polar(v1, 0, 1));
                var v25 = new Vector2(v16.X + (v18.X - v16.X) / 2, v16.Y - (v16.Y - v17.Y) / 2);
                var v26 = new Vector2(v18.X + (v19.X - v18.X) / 2, v1.Y);
                var v27 = fun.Polar(v2, 0, (v15.X - v2.X) / 2);
                var v28 = fun.mirrorpoint(v27, v1, fun.Polar(v1, 0, 1));
                var z = 5;
                var p = 1.27 * z;
                var v36 = fun.Polar(fun.Polar(v13, 0, 40), 90 * pi / 180, 30);
                var v36p = fun.Polar(v36, pi, p / 4 + 0.2 * d1);
                var v29 = fun.Polar(v36, -90 * pi / 180 - 27.5 * pi / 180, p / 4 / Math.Sin(27.5 * pi / 180));
                var v29p = fun.Polar(v36, -90 * pi / 180 - 27.5 * pi / 180, p / 4 / Math.Sin(27.5 * pi / 180) - 0.174 * z / Math.Tan(27.5 * pi / 180) / 2);
                var v30 = fun.Polar(v29, 90 * pi / 180 - 27.5 * pi / 180, p / 2 / Math.Sin(27.5 * pi / 180));
                var v31 = fun.Polar(v29, 0, p);
                var v32 = fun.Polar(v30, 0, p);
                var v33 = fun.Polar(v31, 0, p);
                var v34 = fun.Polar(v32, 0, p);
                var v35 = fun.Polar(v33, 0, p);
                var v35p = fun.Polar(v35, (90 + 27.5) * pi / 180, 0.174 * z / Math.Tan(27.5 * pi / 180) / 2);
                var v37 = fun.Polar(v36, 0, 3 * p);
                var v37p = fun.Polar(v37, 0, 0.2 * d1);



                var v1p = fun.Polar(v36p, -90 * pi / 180, 80);
                var v0p = fun.Polar(v37p, -90 * pi / 180, 80);


                var polyline1 = Pus.AddPointsToLwPolyLine(v2, v15, v16, v18, v19, v24, v23, v21, v20, v7, v2);
                fun.PolyFill(dxf, polyline1, 0.2, contour);
                var line1 = new Line(v10, v8);
                fun.drawBline(dxf, line1, 0.2, contour);
                var line2 = new Line(v11, v9);
                fun.drawBline(dxf, line2, 0.2, contour);
                var line3 = new Line(v16, v21);
                fun.drawBline(dxf, line3, 0.2, contour);
                var line4 = new Line(v18, v23);
                fun.drawBline(dxf, line4, 0.2, contour);
                var line5 = new Line(v17, v19);
                line5.Layer = additionalline;
                line5.Lineweight = Lineweight.W25;
                dxf.AddEntity(line5);
                var line6 = new Line(v22, v24);
                line6.Layer = additionalline;
                line6.Lineweight = Lineweight.W25;
                dxf.AddEntity(line6);
                var line7 = new Line(v13, v14);
                line7.Layer = centre;
                line7.Lineweight = Lineweight.W25;
                line7.Linetype = Linetype.DashDot;
                dxf.AddEntity(line7);
                var line8 = new Line(v36p, v37p);
                line8.Layer = centre;
                line8.Lineweight = Lineweight.W25;
                line8.Linetype = Linetype.DashDot;
                dxf.AddEntity(line8);
                var polyline2 = Pus.AddPointsToLwPolyLine(v29p, v30, v31, v32, v33, v34, v35p);
                var polyline3 = Pus.Fillet4LwPline(polyline2, 1, 0.174 * z / 2);
                var polyline4 = Pus.Fillet4LwPline(polyline3, 3, 0.174 * z / 2);
                var polyline5 = Pus.Fillet4LwPline(polyline4, 5, 0.174 * z / 2);
                var polyline6 = Pus.Fillet4LwPline(polyline5, 7, 0.174 * z / 2);
                var polyline7 = Pus.Fillet4LwPline(polyline6, 9, 0.174 * z / 2);
                fun.PolyFill(dxf, polyline7, 0.2, contour);
                var polyline8 = Pus.AddPointsToLwPolyLine(v10, v12, v11);
                polyline8.Vertexes[0].Bulge = Math.Tan(90 * Math.PI / 180 / 4);
                polyline8.Vertexes[1].Bulge = Math.Tan(-90 * Math.PI / 180 / 4);
                polyline8.Lineweight = Lineweight.W25;
                polyline8.Layer = additionalline;
                dxf.AddEntity(polyline8);

                //标注
                fun.jz(dxf, v27, 90, 3, "A");


                Text text1 = new Text(l1 + "", v1, height, 0);
                var l1_ = text1.Value.Length * height * 0.7;
                fun.dimrot1(dxf, v7, v24, 180, offset * 3, l1_, height, arrowsize, exline, "LS=" + l1, "", " ");
                Text text2 = new Text(l3 + "", v1, height, 0);
                var l3_ = text2.Value.Length * height * 0.7 * 0.1;
                fun.dimrot1(dxf, v20, v24, 180, offset * 1.5, l3_, height, arrowsize, exline, "THLGTH=" + l3, "", "");
                Text text3 = new Text(d + "", v1, height, 0);
                var arc2 = Pus.GetArcFromPline(polyline7, 1);
                var arc2Cen = Pus.ToV2(arc2.Center);
                var c1 = fun.Polar(arc2Cen, 90 * pi / 180, 0.174 * z / 2);
                if (d1 < 20)
                {
                    var d_ = text3.Value.Length * height * 0.7;
                    fun.dimrot1(dxf, v18, v23, -90, offset, d_ * 0.1, height, arrowsize, exline, "TD=" + d, "", "");
                    Text text5 = new Text(d2 + "", v1, height, 0);
                    var d2_ = text5.Value.Length * height * 0.7;
                    fun.Singlearrow(dxf, v36, 180, 5, -90, 25, arrowsize, exline, height, d2_ * 0.5, "d2=" + d2, " ", "");
                    fun.Singlearrow(dxf, c1, 180, 15, -90, 25, arrowsize, exline, height, d_ * 0.5, "TD=" + d, " ", "");
                }
                else
                {
                    var d_ = text3.Value.Length * height * 0.7 * 0.1;
                    fun.dimrot1(dxf, v18, v23, -90, offset, d_, height, arrowsize, exline, "TD=" + d, " ", "");
                    Text text5 = new Text(d2 + "", v1, height, 0);
                    var d2_ = text5.Value.Length * height * 0.7;
                    fun.Singlearrow(dxf, v36, 180, 5, -90, 25, arrowsize, exline, height, d2_ * 0.5, "d2=" + d2, " ", "");
                    fun.Singlearrow(dxf, c1, 180, 15, -90, 25, arrowsize, exline, height, d_ * 0.5, "TD=" + d, " ", "");
                }

                Text text4 = new Text(d1 + "", v1, height, 0);
                var d1_ = text4.Value.Length * height * 0.7;
                fun.dimrot1(dxf, v15, v20, 90, offset * 0.3, d1_, height, arrowsize, exline, "DCONMS=" + d1, "  ", "");

                fun.jdbz2(dxf, new Line(v31, v32), new Line(v31, v30), offset * 1.5, height, arrowsize, exline, "55°", " ", "");
                fun.jdbz2(dxf, new Line(v31, fun.Polar(v31, 90 * pi / 180, 0.1)), new Line(v31, v30), offset, height, arrowsize, exline, "27°30'", " ", "");
                fun.dimrot1(dxf, v31, v33, 0, offset * 2, 0, height, arrowsize, exline, "1.27(25.4/20)", "", "");

                var arc3 = Pus.GetArcFromPline(polyline7, 4);
                var arc3Cen = Pus.ToV2(arc3.Center);
                var c2 = fun.Polar(arc3Cen, -90 * pi / 180, 0.174 * z / 2);
                var arc4 = Pus.GetArcFromPline(polyline7, 5);
                var arc4Cen = Pus.ToV2(arc4.Center);
                var c3 = fun.Polar(arc4Cen, 90 * pi / 180, 0.174 * z / 2);
                fun.dimrot1(dxf, c2, c3, -90, offset, 0, height, arrowsize, exline, "0.813", "", "");
                fun.jt(dxf, c2, -45, 5, height, "R0.174");

                var circle1 = new Circle(v25, (v18.X - v16.X) * 0.2);
                dxf.AddEntity(circle1);
                fun.text(dxf, fun.Polar(fun.Polar(v25, 90 * pi / 180, (v18.X - v16.X) / 2), pi, height * 0.7 / 4), height, "Z");
                fun.text(dxf, fun.Polar(fun.Polar(v36p, 0 * pi / 180, (v37p.X - v36p.X) / 2), 90 * pi / 180, 25), height, "Z");

                var circle2 = new Circle(v26, (v19.Y - v24.Y) * 0.4);
                dxf.AddEntity(circle2);
                fun.text(dxf, fun.Polar(fun.Polar(v26, 0 * pi / 180, (v18.X - v16.X) / 2), pi, height * 0.7 / 4), height, "Y");



                //var s1 = "B 1.6/ 6.3";
                string[] s = Milling_cutter.MatchData(s1);
                var kx = s[0];

                //var D = Convert.ToDouble(s[1]) * z * 0.75;
                //double D1 = Convert.ToDouble(s[2]) * z * 0.75;

                if (kx.Equals("A"))
                {
                    var D = 1.6 * z * 0.75;
                    double D1 = 4 * z * 0.75;

                    var line9 = new Line(v1p, v0p);
                    line9.Layer = centre;
                    line9.Lineweight = Lineweight.W25;
                    line9.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line9);

                    var v46 = fun.Polar(fun.Polar(v0p, pi, 1.5), 90 * pi / 180, D1 / 2);
                    var v47 = fun.mirrorpoint(v46, v0p, v1p);
                    var v49p = fun.Inters(v46, fun.Polar(v46, -150 * pi / 180, 1), v1p, v0p);
                    var v52 = fun.Polar(v49p, pi, D / 3);
                    var v50 = fun.Polar(v49p, 90 * pi / 180, D / 2);
                    var v51 = fun.mirrorpoint(v50, v1p, v0p);
                    var v49 = fun.Inters(v46, fun.Polar(v46, -150 * pi / 180, 1), v50, fun.Polar(v50, 0, 1));
                    var v48 = fun.mirrorpoint(v49, v1p, v0p);
                    var v38 = fun.Polar(v46, 90 * pi / 180, D1 / 2 * 2 / 3);
                    var v45 = fun.mirrorpoint(v38, v1p, v0p);
                    var polyline9 = Pus.AddPointsToLwPolyLine(v38, v46, v49, v50, v52, v51, v48, v47, v45);
                    fun.PolyFill(dxf, polyline9, 0.2, contour);
                    var line10 = new Line(v50, v51);
                    fun.drawBline(dxf, line10, 0.2, contour);
                    var line11 = new Line(v49, v48);
                    fun.drawBline(dxf, line11, 0.2, contour);
                    var line12 = new Line(v46, v47);
                    fun.drawBline(dxf, line12, 0.2, contour);
                    var v39 = fun.Polar(v38, 181 * pi / 180, 0.596 * D1);
                    var v40 = fun.Polar(v39, 180 * pi / 180, 0.342 * D1);
                    var v41 = fun.Polar(v40, 219 * pi / 180, 0.487 * D1);
                    var v42 = fun.Polar(v41, 264 * pi / 180, 0.797 * D1);
                    var v43 = fun.Polar(v42, 287 * pi / 180, 0.616 * D1);
                    var v44 = fun.Polar(v43, 353 * pi / 180, 0.344 * D1);
                    var v44p = fun.Polar(v44, 357 * pi / 180, 0.596 * D1);
                    var polyline10 = Pus.AddPointsToLwPolyLine(v38, v39, v40, v41, v42, v43, v44, v44p, v45);
                    polyline10.Vertexes[0].Bulge = Math.Tan(36 * Math.PI / 180 / 4);
                    polyline10.Vertexes[1].Bulge = Math.Tan(-25 * Math.PI / 180 / 4);
                    polyline10.Vertexes[2].Bulge = Math.Tan(93 * Math.PI / 180 / 4);
                    polyline10.Vertexes[3].Bulge = Math.Tan(-11 * Math.PI / 180 / 4);
                    polyline10.Vertexes[4].Bulge = Math.Tan(59 * Math.PI / 180 / 4);
                    polyline10.Vertexes[5].Bulge = Math.Tan(62 * Math.PI / 180 / 4);
                    polyline10.Vertexes[6].Bulge = Math.Tan(-45 * Math.PI / 180 / 4);
                    polyline10.Vertexes[7].Bulge = Math.Tan(34 * Math.PI / 180 / 4);
                    polyline10.Lineweight = Lineweight.W25;
                    polyline10.Layer = additionalline;
                    dxf.AddEntity(polyline10);

                    var polyline11 = Pus.AddPointsToLwPolyLine(v38, v39, v40, v41, v42, v43, v44, v44p, v45, v47, v48, v51, v52, v50, v49, v46, v38);
                    polyline11.Vertexes[0].Bulge = Math.Tan(36 * Math.PI / 180 / 4);
                    polyline11.Vertexes[1].Bulge = Math.Tan(-25 * Math.PI / 180 / 4);
                    polyline11.Vertexes[2].Bulge = Math.Tan(93 * Math.PI / 180 / 4);
                    polyline11.Vertexes[3].Bulge = Math.Tan(-11 * Math.PI / 180 / 4);
                    polyline11.Vertexes[4].Bulge = Math.Tan(59 * Math.PI / 180 / 4);
                    polyline11.Vertexes[5].Bulge = Math.Tan(62 * Math.PI / 180 / 4);
                    polyline11.Vertexes[6].Bulge = Math.Tan(-45 * Math.PI / 180 / 4);
                    polyline11.Vertexes[7].Bulge = Math.Tan(40 * Math.PI / 180 / 4);
                    String[] htype1 = new String[100];
                    Line[] hline1 = new Line[100];
                    Arc[] harc1 = new Arc[100];
                    int hnumst1 = polyline11.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst1; i++)
                    {
                        htype1[i] = polyline11.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype1[i] == "Line")
                        {
                            hline1[i] = (Line)polyline11.Explode()[i];
                        }
                        if (htype1[i] == "Arc")
                        {
                            harc1[i] = (Arc)polyline11.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);

                    fun.jdbz1(dxf, new Line(v49, v46), new Line(v48, v47), offset * 3, "60°", height);

                    fang.gcbz(dxf, fun.Polar(v47, -30 * pi / 180, 10), 10, -120, 5, 180, 7, arrowsize, 1, "A", "0.02", height, "ytd", 1);

                    fun.text(dxf, fun.Polar(fun.Polar(v1p, 0 * pi / 180, (v0p.X - v1p.X) / 2), 90 * pi / 180, 25), height, "Y");
                }
                if (kx.Equals("B"))
                {

                    var D = 1.6 * z * 0.75;
                    double D1 = 4 * z * 0.75;
                    double D2 = 5 * z * 0.75;

                    var line9 = new Line(v1p, v0p);
                    line9.Layer = centre;
                    line9.Lineweight = Lineweight.W25;
                    line9.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line9);

                    var v46 = fun.Polar(fun.Polar(v0p, pi, 1.5), 90 * pi / 180, D1 / 2);
                    var v47 = fun.mirrorpoint(v46, v0p, v1p);
                    var v49p = fun.Inters(v46, fun.Polar(v46, -150 * pi / 180, 1), v1p, v0p);
                    var v52 = fun.Polar(v49p, pi, D / 3);
                    var v50 = fun.Polar(v49p, 90 * pi / 180, D / 2);
                    var v51 = fun.mirrorpoint(v50, v1p, v0p);
                    var v49 = fun.Inters(v46, fun.Polar(v46, -150 * pi / 180, 1), v50, fun.Polar(v50, 0, 1));
                    var v48 = fun.mirrorpoint(v49, v1p, v0p);
                    var v38 = fun.Polar(v46, 90 * pi / 180, D1 / 2 * 2 / 3);
                    var v45 = fun.mirrorpoint(v38, v1p, v0p);
                    var v46p1 = fun.Polar(fun.Polar(v0p, pi, 1.5), 90 * pi / 180, D2 / 2);
                    var v46p2 = fun.Inters(v46, v49, v46p1, fun.Polar(v46p1, -120 * pi / 180, 1));
                    var v47p1 = fun.mirrorpoint(v46p1, v1p, v0p);
                    var v47p2 = fun.mirrorpoint(v46p2, v1p, v0p);
                    var polyline9 = Pus.AddPointsToLwPolyLine(v38, v46p1, v46p2, v49, v50, v52, v51, v48, v47p2, v47p1, v45);
                    fun.PolyFill(dxf, polyline9, 0.2, contour);
                    var line10 = new Line(v50, v51);
                    fun.drawBline(dxf, line10, 0.2, contour);
                    var line11 = new Line(v49, v48);
                    fun.drawBline(dxf, line11, 0.2, contour);
                    var line12 = new Line(v46p1, v47p1);
                    fun.drawBline(dxf, line12, 0.2, contour);
                    var v39 = fun.Polar(v38, 181 * pi / 180, 0.596 * D1);
                    var v40 = fun.Polar(v39, 180 * pi / 180, 0.342 * D1);
                    var v41 = fun.Polar(v40, 219 * pi / 180, 0.487 * D1);
                    var v42 = fun.Polar(v41, 264 * pi / 180, 0.797 * D1);
                    var v43 = fun.Polar(v42, 287 * pi / 180, 0.616 * D1);
                    var v44 = fun.Polar(v43, 353 * pi / 180, 0.344 * D1);
                    var v44p = fun.Polar(v44, 357 * pi / 180, 0.596 * D1);
                    var polyline10 = Pus.AddPointsToLwPolyLine(v38, v39, v40, v41, v42, v43, v44, v44p, v45);
                    polyline10.Vertexes[0].Bulge = Math.Tan(36 * Math.PI / 180 / 4);
                    polyline10.Vertexes[1].Bulge = Math.Tan(-25 * Math.PI / 180 / 4);
                    polyline10.Vertexes[2].Bulge = Math.Tan(93 * Math.PI / 180 / 4);
                    polyline10.Vertexes[3].Bulge = Math.Tan(-11 * Math.PI / 180 / 4);
                    polyline10.Vertexes[4].Bulge = Math.Tan(59 * Math.PI / 180 / 4);
                    polyline10.Vertexes[5].Bulge = Math.Tan(62 * Math.PI / 180 / 4);
                    polyline10.Vertexes[6].Bulge = Math.Tan(-45 * Math.PI / 180 / 4);
                    polyline10.Vertexes[7].Bulge = Math.Tan(34 * Math.PI / 180 / 4);
                    polyline10.Lineweight = Lineweight.W25;
                    polyline10.Layer = additionalline;
                    dxf.AddEntity(polyline10);

                    var polyline11 = Pus.AddPointsToLwPolyLine(v38, v39, v40, v41, v42, v43, v44, v44p, v45, v47p1, v47p2, v48, v51, v52, v50, v49, v46p2, v46p1, v38);
                    polyline11.Vertexes[0].Bulge = Math.Tan(36 * Math.PI / 180 / 4);
                    polyline11.Vertexes[1].Bulge = Math.Tan(-25 * Math.PI / 180 / 4);
                    polyline11.Vertexes[2].Bulge = Math.Tan(93 * Math.PI / 180 / 4);
                    polyline11.Vertexes[3].Bulge = Math.Tan(-11 * Math.PI / 180 / 4);
                    polyline11.Vertexes[4].Bulge = Math.Tan(59 * Math.PI / 180 / 4);
                    polyline11.Vertexes[5].Bulge = Math.Tan(62 * Math.PI / 180 / 4);
                    polyline11.Vertexes[6].Bulge = Math.Tan(-45 * Math.PI / 180 / 4);
                    polyline11.Vertexes[7].Bulge = Math.Tan(40 * Math.PI / 180 / 4);
                    String[] htype1 = new String[100];
                    Line[] hline1 = new Line[100];
                    Arc[] harc1 = new Arc[100];
                    int hnumst1 = polyline11.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst1; i++)
                    {
                        htype1[i] = polyline11.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype1[i] == "Line")
                        {
                            hline1[i] = (Line)polyline11.Explode()[i];
                        }
                        if (htype1[i] == "Arc")
                        {
                            harc1[i] = (Arc)polyline11.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);

                    fun.jdbz1(dxf, new Line(v49, v46p2), new Line(v48, v47p2), offset * 3.2, "60°", height);
                    fun.jdbz1(dxf, new Line(v46p2, v46p1), new Line(v47p2, v47p1), offset * 4, "120°", height);

                    fang.gcbz(dxf, fun.Polar(v47, -30 * pi / 180, 10), 10, -120, 5, 180, 7, arrowsize, 1, "A", "0.02", height, "ytd", 1);

                    fun.text(dxf, fun.Polar(fun.Polar(v1p, 0 * pi / 180, (v0p.X - v1p.X) / 2), 90 * pi / 180, 25), height, "Y");
                }


            }


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);

            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }




            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Milling_shankDictionary(DxfDocument dxf, Vector2 hp1, double d1, double bbxz, double L, double l, double D, Dictionary<string, Object> data)//hp1=一个点；d1=尾部直径；bbxz=6131.（）在减一就是；L=总长；l=hp1到最前面刀尖点的距离；
                                                                                                                                      // d=刀尖直径
        {
           

            //图层
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //参数
            double pi = Math.PI;
            //参数


            

            double l1;
            double l2;
            double l3;
            double l4;
            double l5;
            double h;
            double r2;
            double d;
            double d2;
            string s1 = "A 1.6/ 4";




            if (bbxz == 0)
            {
                h = 0;
                l2 = 0;
                l3 = 0;
                l4 = 0;
                l5 = 0;
                r2 = 0;
                d = 0;
                d2 = 0;
                if (d1 == 3)
                {
                    l1 = 28;
                }
                else if (d1 == 4)
                {
                    l1 = 28;
                }
                else if (d1 == 5)
                {
                    l1 = 28;
                }
                else if (d1 == 6)
                {
                    l1 = 36;
                }
                else if (d1 == 8)
                {
                    l1 = 36;
                }
                else if (d1 == 10)
                {
                    l1 = 40;
                }
                else if (d1 == 12)
                {
                    l1 = 45;
                }
                else if (d1 == 14)
                {
                    l1 = 45;
                }
                else if (d1 == 16)
                {
                    l1 = 48;
                }
                else if (d1 == 18)
                {
                    l1 = 48;
                }
                else if (d1 == 20)
                {
                    l1 = 50;
                }
                else if (d1 == 25)
                {
                    l1 = 56;
                }
                else if (d1 == 32)
                {
                    l1 = 60;
                }
                else if (d1 == 40)
                {
                    l1 = 70;
                }
                else if (d1 == 50)
                {
                    l1 = 80;
                }
                else if (d1 == 63)
                {
                    l1 = 90;
                }
                else
                {
                    l1 = 0;
                }

            }
            else if (bbxz == 1)
            {
                l5 = 0;
                r2 = 0;
                d = 0;
                d2 = 0;
                if (d1 == 6)
                {
                    l1 = 36;
                    l2 = 18;
                    l3 = 4.2;
                    l4 = 0;
                    h = 4.8;
                }
                else if (d1 == 8)
                {
                    l1 = 36;
                    l2 = 18;
                    l3 = 5.5;
                    l4 = 0;
                    h = 6.6;
                }
                else if (d1 == 10)
                {
                    l1 = 40;
                    l2 = 20;
                    l3 = 7;
                    l4 = 0;
                    h = 8.4;
                }
                else if (d1 == 12)
                {
                    l1 = 45;
                    l2 = 22.5;
                    l3 = 8;
                    l4 = 0;
                    h = 10.4;
                }
                else if (d1 == 14)
                {
                    l1 = 45;
                    l2 = 22.5;
                    l3 = 8;
                    l4 = 0;
                    h = 12.7;
                }
                else if (d1 == 16)
                {
                    l1 = 48;
                    l2 = 24;
                    l3 = 10;
                    l4 = 0;
                    h = 14.2;
                }
                else if (d1 == 18)
                {
                    l1 = 48;
                    l2 = 24;
                    l3 = 10;
                    l4 = 0;
                    h = 16.2;
                }
                else if (d1 == 20)
                {
                    l1 = 50;
                    l2 = 25;
                    l3 = 11;
                    l4 = 0;
                    h = 18.2;
                }
                else if (d1 == 25)
                {
                    l1 = 56;
                    l2 = 32;
                    l3 = 12;
                    l4 = 17;
                    h = 23;
                }
                else if (d1 == 32)
                {
                    l1 = 60;
                    l2 = 36;
                    l3 = 14;
                    l4 = 19;
                    h = 30;
                }
                else if (d1 == 40)
                {
                    l1 = 70;
                    l2 = 40;
                    l3 = 14;
                    l4 = 19;
                    h = 38;
                }
                else if (d1 == 50)
                {
                    l1 = 80;
                    l2 = 45;
                    l3 = 18;
                    l4 = 23;
                    h = 47.8;
                }
                else if (d1 == 63)
                {
                    l1 = 90;
                    l2 = 50;
                    l3 = 18;
                    l4 = 23;
                    h = 60.8;
                }
                else
                {
                    l1 = 0;
                    l2 = 0;
                    l3 = 0;
                    l4 = 0;
                    l5 = 0;
                    h = 0;
                    r2 = 0;
                    d = 5.9;
                    d2 = 5.087;
                }

            }
            else if (bbxz == 2)
            {
                l2 = 0;
                l3 = 0;
                d = 0;
                d2 = 0;
                if (d1 == 6)
                {
                    h = 4.8;
                    l1 = 36;
                    l4 = 26;
                    l5 = 18;
                    r2 = 1.2;
                }
                else if (d1 == 8)
                {
                    h = 6.6;
                    l1 = 36;
                    l4 = 26;
                    l5 = 18;
                    r2 = 1.2;
                }
                else if (d1 == 10)
                {
                    h = 8.4;
                    l1 = 40;
                    l4 = 28;
                    l5 = 20;
                    r2 = 1.2;
                }
                else if (d1 == 12)
                {
                    h = 10.4;
                    l1 = 45;
                    l4 = 33;
                    l5 = 22.5;
                    r2 = 1.2;
                }
                else if (d1 == 16)
                {
                    h = 14.2;
                    l1 = 48;
                    l4 = 36;
                    l5 = 24;
                    r2 = 1.6;
                }
                else if (d1 == 20)
                {
                    h = 18.2;
                    l1 = 50;
                    l4 = 38;
                    l5 = 25;
                    r2 = 1.6;
                }
                else if (d1 == 25)
                {
                    h = 23.0;
                    l1 = 56;
                    l4 = 44;
                    l5 = 53;
                    r2 = 1.6;
                }
                else if (d1 == 32)
                {
                    h = 30.0;
                    l1 = 60;
                    l4 = 48;
                    l5 = 35;
                    r2 = 1.6;
                }
                else if (d1 == 40)
                {
                    h = 37.8;
                    l1 = 70;
                    l4 = 56;
                    l5 = 41;
                    r2 = 1.6;
                }
                else if (d1 == 50)
                {
                    h = 47.2;
                    l1 = 80;
                    l4 = 60;
                    l5 = 49;
                    r2 = 1.6;
                }
                else
                {
                    l1 = 0;
                    l2 = 0;
                    l3 = 0;
                    l4 = 0;
                    l5 = 0;
                    h = 0;
                    r2 = 0;
                    d = 0;
                    d2 = 0;
                }

            }
            else if (bbxz == 3)
            {
                h = 0;
                l2 = 0;
                l4 = 0;
                l5 = 0;
                r2 = 0;
                if (d1 == 6)
                {
                    d = 5.9;
                    d2 = 2.087;
                    l1 = 36;
                    l3 = 10;
                }
                else if (d1 == 10)
                {
                    d = 9.9;
                    d2 = 9.087;
                    l1 = 40;
                    l3 = 10;
                }
                else if (d1 == 12)
                {
                    d = 11.9;
                    d2 = 11.087;
                    l1 = 45;
                    l3 = 10;
                }
                else if (d1 == 16)
                {
                    d = 15.9;
                    d2 = 15.087;
                    l1 = 48;
                    l3 = 10;
                }
                else if (d1 == 20)
                {
                    d = 19.9;
                    d2 = 19.087;
                    l1 = 50;
                    l3 = 15;
                }
                else if (d1 == 25)
                {
                    d = 24.9;
                    d2 = 24.087;
                    l1 = 56;
                    l3 = 15;
                }
                else if (d1 == 32)
                {
                    d = 31.9;
                    d2 = 31.087;
                    l1 = 60;
                    l3 = 15;
                }
                else
                {
                    l1 = 0;
                    l2 = 0;
                    l3 = 0;
                    l4 = 0;
                    l5 = 0;
                    h = 0;
                    r2 = 0;
                    d = 5.9;
                    d2 = 5.087;
                }
            }
            else
            {
                l1 = 0;
                l2 = 0;
                l3 = 0;
                l4 = 0;
                l5 = 0;
                h = 0;
                r2 = 0;
                d = 5.9;
                d2 = 5.087;
            }




            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度

            if (bbxz == 0)
            {
                var v1 = fun.Polar(hp1, 0, L - l - l1);
                var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
                var v3p = fun.Polar(v2, 0, l1);
                var v3 = fun.Polar(v3p, pi, 0.1 * d1);
                var v4 = fun.Polar(v3p, -90 * pi / 180, 0.1 * d1);
                var v5 = fun.mirrorpoint(v4, v1, fun.Polar(v1, 0, 1));
                var v6 = fun.mirrorpoint(v3, v1, fun.Polar(v1, 0, 1));
                var v7 = fun.mirrorpoint(v2, v1, fun.Polar(v1, 0, 1));
                var v8 = fun.Polar(v1, 90 * pi / 180, (3.27 / 4.04 * D) / 2);
                var v9 = fun.mirrorpoint(v8, v1, fun.Polar(v1, 0, 1));
                var v10 = fun.Polar(v8, pi, L - l - l1);
                var v11 = fun.Polar(v9, pi, L - l - l1);
                var v12 = fun.Polar(v1, pi, L - l - l1);
                var v13 = fun.Polar(v1, 0, l1 + 0.05 * l1);
                var v14 = fun.Polar(v12, pi, 0.05 * l1);

                var polyline1 = Pus.AddPointsToLwPolyLine(v2, v3, v4, v5, v6, v7, v2);
                fun.PolyFill(dxf, polyline1, 0.2, contour);
                var line1 = new Line(v3, v6);
                fun.drawBline(dxf, line1, 0.2, contour);
                var line2 = new Line(v10, v8);
                fun.drawBline(dxf, line2, 0.2, contour);
                var line3 = new Line(v11, v9);
                fun.drawBline(dxf, line3, 0.2, contour);
                var polyline2 = Pus.AddPointsToLwPolyLine(v10, v12, v11);
                polyline2.Vertexes[0].Bulge = Math.Tan(90 * Math.PI / 180 / 4);
                polyline2.Vertexes[1].Bulge = Math.Tan(-90 * Math.PI / 180 / 4);
                polyline2.Lineweight = Lineweight.W25;
                polyline2.Layer = additionalline;
                //dxf.AddEntity(polyline2);
                var line4 = new Line(v14, v13);
                line4.Layer = center;
                line4.Lineweight = Lineweight.W25;
                line4.Linetype = Linetype.DashDot;
                //dxf.AddEntity(line4);



                Text text1 = new Text(l1 + "", v1, height, 0);
                var l1_ = text1.Value.Length * height * 0.7;
                Text text2 = new Text(d1 + "", v1, height, 0);
                var d1_ = text2.Value.Length * height * 0.7;

                fun.dimrot1(dxf, v7, v5, 180, 10, l1_, height, arrowsize, exline, "LS=" + l1, "", "");// "+2", "0");
                fun.dimrot1(dxf, v3, v6, -90, 10, d1_, height, arrowsize, exline, "DCONMS=" + d1, "", "");// "", "h8");
            }
            if (bbxz == 1)
            {
                var v1 = fun.Polar(hp1, 0, L - l - l1);
                var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
                var v3p = fun.Polar(v2, 0, l1);
                var v3 = fun.Polar(v3p, pi, (d1 - h) / 2 * 0.95);
                var v4 = fun.Polar(v3p, -90 * pi / 180, (d1 - h) / 2 * 0.95);
                var v5 = fun.mirrorpoint(v4, v1, fun.Polar(v1, 0, 1));
                var v6 = fun.mirrorpoint(v3, v1, fun.Polar(v1, 0, 1));
                var v7 = fun.mirrorpoint(v2, v1, fun.Polar(v1, 0, 1));
                var v8 = fun.Polar(v1, 90 * pi / 180, (3.27 / 4.04 * D) / 2);
                var v9 = fun.mirrorpoint(v8, v1, fun.Polar(v1, 0, 1));
                var v10 = fun.Polar(v8, pi, L - l - l1);
                var v11 = fun.Polar(v9, pi, L - l - l1);
                var v12 = fun.Polar(v1, pi, L - l - l1);
                var v13 = fun.Polar(v1, 0, l1 + 0.05 * l1);
                var v14 = fun.Polar(v12, pi, 0.05 * l1);
                var v15 = fun.Polar(v13, 0, 3 * d1);
                var v16 = fun.Polar(v15, 90 * pi / 180, 0.65 * d1);
                var v17 = fun.Polar(v15, -90 * pi / 180, 0.65 * d1);
                var v18 = fun.Polar(v15, pi, 0.65 * d1);
                var v19 = fun.Polar(v15, 0, 0.65 * d1);
                var v20 = new Vector2(v15.X - Math.Sqrt(Math.Pow(d1 / 2, 2) - Math.Pow(h - d1 / 2, 2)), v15.Y + h - d1 / 2);
                var v21 = new Vector2(v15.X + Math.Sqrt(Math.Pow(d1 / 2, 2) - Math.Pow(h - d1 / 2, 2)), v15.Y + h - d1 / 2);
                var v23 = new Vector2(v3p.X - l2 - l3 / 2, v20.Y);
                var v24 = fun.Polar(v23, 0, l3);
                var v22 = fun.Inters(v23, fun.Polar(v23, 135 * pi / 180, 1), v2, v3);
                var v25 = fun.Inters(v24, fun.Polar(v24, 45 * pi / 180, 1), v2, v3);
                var v27 = new Vector2(v3p.X - l4, v24.Y);
                var v26 = fun.Inters(v27, fun.Polar(v27, 135 * pi / 180, 1), v2, v3p);
                var v28 = fun.Inters(v27, fun.Polar(v27, 0, 1), v6, v3);
                var v29 = new Vector2(v5.X, v28.Y);
                var d02 = fun.CalDistance(v4, v5);
                var v30 = new Vector2(v15.X - Math.Sqrt(Math.Pow(d02 / 2, 2) - Math.Pow(h - d1 / 2, 2)), v15.Y + h - d1 / 2);
                var v31 = new Vector2(v15.X + Math.Sqrt(Math.Pow(d02 / 2, 2) - Math.Pow(h - d1 / 2, 2)), v15.Y + h - d1 / 2);
                var v32 = new Vector2(v23.X + (v24.X - v23.X) / 2, v23.Y + (v25.Y - v24.Y) * 2);
                var v33 = fun.mirrorpoint(v32, v12, v13);

                if (d1 >= 6 && d1 <= 20)
                {
                    var polyline1 = Pus.AddPointsToLwPolyLine(v2, v22, v23, v24, v25, v3, v4, v5, v6, v7, v2);
                    fun.PolyFill(dxf, polyline1, 0.2, contour);
                    var line1 = new Line(v3, v6);
                    fun.drawBline(dxf, line1, 0.2, contour);
                    var line2 = new Line(v10, v8);
                    fun.drawBline(dxf, line2, 0.2, contour);
                    var line3 = new Line(v11, v9);
                    fun.drawBline(dxf, line3, 0.2, contour);
                    var polyline2 = Pus.AddPointsToLwPolyLine(v10, v12, v11);
                    polyline2.Vertexes[0].Bulge = Math.Tan(90 * Math.PI / 180 / 4);
                    polyline2.Vertexes[1].Bulge = Math.Tan(-90 * Math.PI / 180 / 4);
                    polyline2.Lineweight = Lineweight.W25;
                    polyline2.Layer = additionalline;
                    //dxf.AddEntity(polyline2);
                    var line4 = new Line(v14, v13);
                    line4.Layer = center;
                    line4.Lineweight = Lineweight.W25;
                    line4.Linetype = Linetype.DashDot;
                    //dxf.AddEntity(line4);
                    var line5 = new Line(v18, v19);
                    line5.Layer = center;
                    line5.Lineweight = Lineweight.W25;
                    line5.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line5);
                    var line6 = new Line(v16, v17);
                    line6.Layer = center;
                    line6.Lineweight = Lineweight.W25;
                    line6.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line6);
                    var line7 = new Line(v32, v33);
                    line7.Layer = center;
                    line7.Lineweight = Lineweight.W25;
                    line7.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line7);
                    var line8 = new Line(v20, v21);
                    fun.drawBline(dxf, line8, 0.2, contour);
                    var polyline3 = Pus.AddPointsToLwPolyLine(fun.Polar(v15, 0, d1 / 2), fun.Polar(v15, pi, d1 / 2), fun.Polar(v15, 0, d1 / 2));
                    polyline3.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                    polyline3.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                    fun.PolyFill(dxf, polyline3, 0.2, contour);
                    var polyline4 = Pus.AddPointsToLwPolyLine(v20, v21, v20);
                    polyline4.Vertexes[0].Bulge = Math.Tan((360 * pi / 180 - (fun.CalAngle(v15, v20) - fun.CalAngle(v15, v21))) / 4);
                    String[] htype1 = new String[100];
                    Line[] hline1 = new Line[100];
                    Arc[] harc1 = new Arc[100];
                    int hnumst1 = polyline4.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst1; i++)
                    {
                        htype1[i] = polyline4.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype1[i] == "Line")
                        {
                            hline1[i] = (Line)polyline4.Explode()[i];
                        }
                        if (htype1[i] == "Arc")
                        {
                            harc1[i] = (Arc)polyline4.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype1, hnumst1, 45, 4, hline1, harc1, hatching);


                    Text text1 = new Text(l1 + "", v1, height, 0);
                    var l1_ = text1.Value.Length * height * 0.7;
                    Text text2 = new Text(d1 + "", v1, height, 0);
                    var d1_ = text2.Value.Length * height * 0.7;
                    Text text3 = new Text(l2 + "", v1, height, 0);
                    var l2_ = text3.Value.Length * height * 0.7;
                    Text text4 = new Text(l3 + "", v1, height, 0);
                    var l3_ = text4.Value.Length * height * 0.7;
                    Text text6 = new Text(h + "", v1, height, 0);
                    var h_ = text6.Value.Length * height * 0.1;

                    fun.dimrot1(dxf, v26, v6, -90, offset * 1, d1_, height, arrowsize, exline, "DCONMS=" + d1, "", "");// "   ", "h");
                    fun.dimrot1(dxf, v7, v5, 180, offset * 2, l1_, height, arrowsize, exline, "LS=" + l1, "", "");// "0", "-0.4");
                    fun.dimrot1(dxf, v33, v5, 0, offset * 3, l2_, height, arrowsize, exline, "l2=" + l2, "", "");// "0  ", "-1");
                    fun.dimrot1(dxf, v23, v24, 0, offset, l3_, height, arrowsize, exline, "l3=" + l3, "", "");// "+0.1", "0");
                    fun.dimrot1(dxf, v21, new Vector2(v15.X, v7.Y), -90, offset, 0, height, arrowsize, exline, "h=" + h, "", "");// "0", "-0.4");
                    fun.jdbz2(dxf, new Line(v24, v25), new Line(v24, fun.Polar(v24, 90 * pi / 180, 0.1)), offset * 1.5, height, arrowsize, exline, "45°", "", "");// "+1°", "0");

                }
                if (d1 >= 25 && d1 <= 63)
                {
                    var polyline1 = Pus.AddPointsToLwPolyLine(v2, v22, v23, v24, v25, v26, v27, v29, v5, v6, v7, v2);
                    fun.PolyFill(dxf, polyline1, 0.2, contour);
                    var line1 = new Line(v28, v6);
                    fun.drawBline(dxf, line1, 0.2, contour);
                    var line2 = new Line(v10, v8);
                    fun.drawBline(dxf, line2, 0.2, contour);
                    var line3 = new Line(v11, v9);
                    fun.drawBline(dxf, line3, 0.2, contour);
                    var polyline2 = Pus.AddPointsToLwPolyLine(v10, v12, v11);
                    polyline2.Vertexes[0].Bulge = Math.Tan(90 * Math.PI / 180 / 4);
                    polyline2.Vertexes[1].Bulge = Math.Tan(-90 * Math.PI / 180 / 4);
                    polyline2.Lineweight = Lineweight.W25;
                    polyline2.Layer = additionalline;
                    //dxf.AddEntity(polyline2);
                    var line4 = new Line(v14, v13);
                    line4.Layer = center;
                    line4.Lineweight = Lineweight.W25;
                    line4.Linetype = Linetype.DashDot;
                    //dxf.AddEntity(line4);
                    var line5 = new Line(v18, v19);
                    line5.Layer = center;
                    line5.Lineweight = Lineweight.W25;
                    line5.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line5);
                    var line6 = new Line(v16, v17);
                    line6.Layer = center;
                    line6.Lineweight = Lineweight.W25;
                    line6.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line6);
                    var line7 = new Line(v32, v33);
                    line7.Layer = center;
                    line7.Lineweight = Lineweight.W25;
                    line7.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line7);
                    var line8 = new Line(v20, v21);
                    fun.drawBline(dxf, line8, 0.2, contour);
                    var polyline3 = Pus.AddPointsToLwPolyLine(fun.Polar(v15, 0, d1 / 2), fun.Polar(v15, pi, d1 / 2), fun.Polar(v15, 0, d1 / 2));
                    polyline3.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                    polyline3.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                    fun.PolyFill(dxf, polyline3, 0.2, contour);
                    var polyline4 = Pus.AddPointsToLwPolyLine(v30, v31);
                    polyline4.Vertexes[0].Bulge = Math.Tan((360 * pi / 180 - (fun.CalAngle(v15, v20) - fun.CalAngle(v15, v21))) / 4);
                    String[] htype1 = new String[100];
                    Line[] hline1 = new Line[100];
                    Arc[] harc1 = new Arc[100];
                    int hnumst1 = polyline4.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst1; i++)
                    {
                        htype1[i] = polyline4.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype1[i] == "Line")
                        {
                            hline1[i] = (Line)polyline4.Explode()[i];
                        }
                        if (htype1[i] == "Arc")
                        {
                            harc1[i] = (Arc)polyline4.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype1, hnumst1, 45, 4, hline1, harc1, hatching);


                    Text text1 = new Text(l1 + "", v1, height, 0);
                    var l1_ = text1.Value.Length * height * 0.7;
                    Text text2 = new Text(d1 + "", v1, height, 0);
                    var d1_ = text2.Value.Length * height * 0.7;
                    Text text3 = new Text(l2 + "", v1, height, 0);
                    var l2_ = text3.Value.Length * height * 0.7;
                    Text text4 = new Text(l3 + "", v1, height, 0);
                    var l3_ = text4.Value.Length * height * 0.7;
                    Text text5 = new Text(l4 + "", v1, height, 0);
                    var l4_ = text5.Value.Length * height * 0.7;
                    Text text6 = new Text(h + "", v1, height, 0);
                    var h_ = text6.Value.Length * height * 0.7;

                    fun.dimrot1(dxf, v26, v6, -90, offset * 3, d1_, height, arrowsize, exline, "DCONMS=" + d1, "", "");// "    ", " h");
                    fun.dimrot1(dxf, v7, v5, 180, offset * 2.5, l1_, height, arrowsize, exline, "LS=" + l1, "", "");// "0", "-0.4");
                    fun.dimrot1(dxf, v33, v5, 180, offset, l2_, height, arrowsize, exline, "l2=" + l2, "", "");// "0  ", "-1");
                    fun.dimrot1(dxf, v23, v24, 0, offset, l3_, height, arrowsize, exline, "l3=" + l3, "", "");// "+0.1", "0");
                    fun.dimrot1(dxf, v27, v29, 0, offset, l4_, height, arrowsize, exline, "l4=" + l4, "", "");// "+1", "0");
                    fun.dimrot1(dxf, v21, new Vector2(v15.X, v7.Y), -90, offset * 2.5, h_, height, arrowsize, exline, "h=" + h, "", "");// "0   ", "-0.4");
                    fun.jdbz2(dxf, new Line(v27, fun.Polar(v27, 90 * pi / 180, 0.1)), new Line(v27, v26), offset * 3, height, arrowsize, exline, "45°", "", "");// "+1°", "0");

                }



            }
            if (bbxz == 2)
            {
                var v1 = fun.Polar(hp1, 0, L - l - l1);
                var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
                var v3p = fun.Polar(v2, 0, l1);
                var v3 = fun.Polar(v3p, pi, (d1 - h) / 2 * 0.95);
                var v4 = fun.Polar(v3p, -90 * pi / 180, (d1 - h) / 2 * 0.95);
                var v5 = fun.mirrorpoint(v4, v1, fun.Polar(v1, 0, 1));
                var v6 = fun.mirrorpoint(v3, v1, fun.Polar(v1, 0, 1));
                var v7 = fun.mirrorpoint(v2, v1, fun.Polar(v1, 0, 1));
                var v8 = fun.Polar(v1, 90 * pi / 180, (3.27 / 4.04 * D) / 2);
                var v9 = fun.mirrorpoint(v8, v1, fun.Polar(v1, 0, 1));
                var v10 = fun.Polar(v8, pi, L - l - l1);
                var v11 = fun.Polar(v9, pi, L - l - l1);
                var v12 = fun.Polar(v1, pi, L - l - l1);
                var v13 = fun.Polar(v1, 0, l1 + 0.05 * l1);
                var v14 = fun.Polar(v12, pi, 0.05 * l1);
                var v15 = fun.Polar(v3p, pi, l4);
                var v16 = fun.Inters(v15, fun.Polar(v15, -43 * pi / 180, 1), v3p, fun.Polar(v3p, -178 * pi / 180, 1));
                var v17 = fun.Inters(v3p, fun.Polar(v3p, -178 * pi / 180, 1), v6, fun.Polar(v6, 90 * pi / 180, 1));
                var v18 = fun.Polar(v3p, pi, l5);
                var v19 = fun.Polar(v18, 90 * pi / 180, d1 / 4);
                var v20 = fun.mirrorpoint(v19, v1, fun.Polar(v1, 0, 1));
                var v21 = fun.Polar(v13, 0, 3 * d1);
                var v22 = fun.Polar(v21, 90 * pi / 180, 0.65 * d1);
                var v23 = fun.Polar(v21, -90 * pi / 180, 0.65 * d1);
                var v24 = fun.Polar(v21, pi, 0.65 * d1);
                var v25 = fun.Polar(v21, 0, 0.65 * d1);
                var v26 = new Vector2(v21.X - Math.Sqrt(Math.Pow(d1 / 2, 2) - Math.Pow(h - d1 / 2, 2)), v21.Y + h - d1 / 2);
                var v27 = new Vector2(v21.X + Math.Sqrt(Math.Pow(d1 / 2, 2) - Math.Pow(h - d1 / 2, 2)), v21.Y + h - d1 / 2);

                var polyline1 = Pus.AddPointsToLwPolyLine(v2, v15, v16, v3p, v5, v6, v7, v2);
                var polyline2 = Pus.Fillet4LwPline(polyline1, 2, r2);
                fun.PolyFill(dxf, polyline2, 0.2, contour);
                var line1 = new Line(v6, v17);
                fun.drawBline(dxf, line1, 0.2, contour);
                var line2 = new Line(v8, v10);
                fun.drawBline(dxf, line2, 0.2, contour);
                var line3 = new Line(v9, v11);
                fun.drawBline(dxf, line3, 0.2, contour);
                var line4 = new Line(v14, v13);
                line4.Layer = center;
                line4.Lineweight = Lineweight.W25;
                line4.Linetype = Linetype.DashDot;
                //dxf.AddEntity(line4);
                var line5 = new Line(v19, v20);
                line5.Layer = center;
                line5.Lineweight = Lineweight.W25;
                line5.Linetype = Linetype.DashDot;
                dxf.AddEntity(line5);
                var line6 = new Line(v24, v25);
                line6.Layer = center;
                line6.Lineweight = Lineweight.W25;
                line6.Linetype = Linetype.DashDot;
                dxf.AddEntity(line6);
                var line7 = new Line(v22, v23);
                line7.Layer = center;
                line7.Lineweight = Lineweight.W25;
                line7.Linetype = Linetype.DashDot;
                dxf.AddEntity(line7);
                var polyline3 = Pus.AddPointsToLwPolyLine(v26, v27, v26);
                polyline3.Vertexes[0].Bulge = Math.Tan((360 * pi / 180 - (fun.CalAngle(v21, v26) - fun.CalAngle(v21, v27))) / 4);
                fun.PolyFill(dxf, polyline3, 0.2, contour);
                var polyline4 = Pus.AddPointsToLwPolyLine(v10, v12, v11);
                polyline4.Vertexes[0].Bulge = Math.Tan(90 * Math.PI / 180 / 4);
                polyline4.Vertexes[1].Bulge = Math.Tan(-90 * Math.PI / 180 / 4);
                polyline4.Lineweight = Lineweight.W25;
                polyline4.Layer = additionalline;
                //dxf.AddEntity(polyline4);
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = polyline3.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = polyline3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)polyline3.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)polyline3.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 4, hline1, harc1, hatching);



                Text text1 = new Text(l1 + "", v1, height, 0);
                var l1_ = text1.Value.Length * height * 0.7;
                Text text2 = new Text(d1 + "", v1, height, 0);
                var d1_ = text2.Value.Length * height * 0.7;
                Text text3 = new Text(l4 + "", v1, height, 0);
                var l4_ = text3.Value.Length * height * 0.7;
                Text text4 = new Text(l5 + "", v1, height, 0);
                var l5_ = text4.Value.Length * height * 0.7;
                Text text6 = new Text(h + "", v1, height, 0);
                var h_ = text6.Value.Length * height * 0.7;

                fun.dimrot1(dxf, fun.Polar(v21, pi, d1 / 2), fun.Polar(v21, 0, d1 / 2), 180, d1 * 2, d1_, height, arrowsize, exline, "DCONMS=" + d1, "", "");// "    ", " h6");
                fun.dimrot1(dxf, v2, v3p, 0, offset * 3, l1_, height, arrowsize, exline, "LS=" + l1, "", "");// "+2", " 0");
                fun.dimrot1(dxf, v15, v3p, 0, offset * 2, l4_, height, arrowsize, exline, "l4=" + l4, " ", "");// " 0", "-1");
                fun.dimrot1(dxf, v19, v3p, 0, offset, l5_, height, arrowsize, exline, "l5=" + l5, "   ", "");
                fun.dimrot1(dxf, v27, fun.Polar(v21, -90 * pi / 180, d1 / 2), -90, d1 * 2, h_ * 0.1, height, arrowsize, exline, "h=" + h, "", "");// "h=" + h, "", "h13");
                fun.jdbz2(dxf, new Line(v15, fun.Polar(v15, 90 * pi / 180, 0.1)), new Line(v15, fun.Polar(v15, (90 + 47) * pi / 180, 0.1)), offset, height, arrowsize, exline, "47°", "", "");// " 0", "-2°");
                fun.jdbz2(dxf, new Line(v3p, fun.Polar(v3p, 180 * pi / 180, 0.1)), new Line(v3p, fun.Polar(v3p, (180 + 2) * pi / 180, 0.1)), offset, height / 2, arrowsize, 0.5, "2°", "", "");// "  0", "-30°");
                var arc = Pus.GetArcFromPline(polyline2, 1);
                var arc2Cen = Pus.ToV2(arc.Center);
                fun.jt1(dxf, fun.Polar(arc2Cen, -133 * pi / 180, r2), 47, r2 * 3, 1, "r2", height);




            }
            if (bbxz == 3)
            {
                var v1 = fun.Polar(hp1, 0, L - l - l1);
                var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
                var v3p = fun.Polar(v2, 0, l1);
                var v3 = fun.Polar(v3p, pi, (d1 - h) / 2 * 0.95);
                var v4 = fun.Polar(v3p, -90 * pi / 180, (d1 - h) / 2 * 0.95);
                var v5 = fun.mirrorpoint(v4, v1, fun.Polar(v1, 0, 1));
                var v6 = fun.mirrorpoint(v3, v1, fun.Polar(v1, 0, 1));
                var v7 = fun.mirrorpoint(v2, v1, fun.Polar(v1, 0, 1));
                var v8 = fun.Polar(v1, 90 * pi / 180, (3.27 / 4.04 * D) / 2);
                var v9 = fun.mirrorpoint(v8, v1, fun.Polar(v1, 0, 1));
                var v10 = fun.Polar(v8, pi, L - l - l1);
                var v11 = fun.Polar(v9, pi, L - l - l1);
                var v12 = fun.Polar(v1, pi, L - l - l1);
                var v13 = fun.Polar(v1, 0, l1 + 0.05 * l1);
                var v14 = fun.Polar(v12, pi, 0.05 * l1);
                var v15 = fun.Polar(v2, 0, (l1 - l3));
                var v16 = fun.Polar(v15, -90 * pi / 180, (d1 - d) / 2);
                var v18p = fun.Polar(v16, 0, l3);
                var v18 = fun.Polar(v18p, pi, (d1 - d) / 2 * 0.95);
                var v19 = fun.Polar(v18p, -90 * pi / 180, (d1 - d) / 2 * 0.95);
                var v17 = new Vector2(v16.X, v19.Y);
                var v20 = fun.mirrorpoint(v15, v1, fun.Polar(v1, 0, 1));
                var v21 = fun.mirrorpoint(v16, v1, fun.Polar(v1, 0, 1));
                var v22 = fun.mirrorpoint(v17, v1, fun.Polar(v1, 0, 1));
                var v23 = fun.mirrorpoint(v18, v1, fun.Polar(v1, 0, 1));
                var v24 = fun.mirrorpoint(v19, v1, fun.Polar(v1, 0, 1));
                var v25 = new Vector2(v16.X + (v18.X - v16.X) / 2, v16.Y - (v16.Y - v17.Y) / 2);
                var v26 = new Vector2(v18.X + (v19.X - v18.X) / 2, v1.Y);
                var v27 = fun.Polar(v2, 0, (v15.X - v2.X) / 2);
                var v28 = fun.mirrorpoint(v27, v1, fun.Polar(v1, 0, 1));
                var z = 5;
                var p = 1.27 * z;
                var v36 = fun.Polar(fun.Polar(v13, 0, 40), 90 * pi / 180, 30);
                var v36p = fun.Polar(v36, pi, p / 4 + 0.2 * d1);
                var v29 = fun.Polar(v36, -90 * pi / 180 - 27.5 * pi / 180, p / 4 / Math.Sin(27.5 * pi / 180));
                var v29p = fun.Polar(v36, -90 * pi / 180 - 27.5 * pi / 180, p / 4 / Math.Sin(27.5 * pi / 180) - 0.174 * z / Math.Tan(27.5 * pi / 180) / 2);
                var v30 = fun.Polar(v29, 90 * pi / 180 - 27.5 * pi / 180, p / 2 / Math.Sin(27.5 * pi / 180));
                var v31 = fun.Polar(v29, 0, p);
                var v32 = fun.Polar(v30, 0, p);
                var v33 = fun.Polar(v31, 0, p);
                var v34 = fun.Polar(v32, 0, p);
                var v35 = fun.Polar(v33, 0, p);
                var v35p = fun.Polar(v35, (90 + 27.5) * pi / 180, 0.174 * z / Math.Tan(27.5 * pi / 180) / 2);
                var v37 = fun.Polar(v36, 0, 3 * p);
                var v37p = fun.Polar(v37, 0, 0.2 * d1);



                var v1p = fun.Polar(v36p, -90 * pi / 180, 80);
                var v0p = fun.Polar(v37p, -90 * pi / 180, 80);


                var polyline1 = Pus.AddPointsToLwPolyLine(v2, v15, v16, v18, v19, v24, v23, v21, v20, v7, v2);
                fun.PolyFill(dxf, polyline1, 0.2, contour);
                var line1 = new Line(v10, v8);
                fun.drawBline(dxf, line1, 0.2, contour);
                var line2 = new Line(v11, v9);
                fun.drawBline(dxf, line2, 0.2, contour);
                var line3 = new Line(v16, v21);
                fun.drawBline(dxf, line3, 0.2, contour);
                var line4 = new Line(v18, v23);
                fun.drawBline(dxf, line4, 0.2, contour);
                var line5 = new Line(v17, v19);
                line5.Layer = additionalline;
                line5.Lineweight = Lineweight.W25;
                dxf.AddEntity(line5);
                var line6 = new Line(v22, v24);
                line6.Layer = additionalline;
                line6.Lineweight = Lineweight.W25;
                dxf.AddEntity(line6);
                var line7 = new Line(v13, v14);
                line7.Layer = center;
                line7.Lineweight = Lineweight.W25;
                line7.Linetype = Linetype.DashDot;
                //dxf.AddEntity(line7);
                var line8 = new Line(v36p, v37p);
                line8.Layer = center;
                line8.Lineweight = Lineweight.W25;
                line8.Linetype = Linetype.DashDot;
                dxf.AddEntity(line8);
                var polyline2 = Pus.AddPointsToLwPolyLine(v29p, v30, v31, v32, v33, v34, v35p);
                var polyline3 = Pus.Fillet4LwPline(polyline2, 1, 0.174 * z / 2);
                var polyline4 = Pus.Fillet4LwPline(polyline3, 3, 0.174 * z / 2);
                var polyline5 = Pus.Fillet4LwPline(polyline4, 5, 0.174 * z / 2);
                var polyline6 = Pus.Fillet4LwPline(polyline5, 7, 0.174 * z / 2);
                var polyline7 = Pus.Fillet4LwPline(polyline6, 9, 0.174 * z / 2);
                fun.PolyFill(dxf, polyline7, 0.2, contour);
                var polyline8 = Pus.AddPointsToLwPolyLine(v10, v12, v11);
                polyline8.Vertexes[0].Bulge = Math.Tan(90 * Math.PI / 180 / 4);
                polyline8.Vertexes[1].Bulge = Math.Tan(-90 * Math.PI / 180 / 4);
                polyline8.Lineweight = Lineweight.W25;
                polyline8.Layer = additionalline;
                //dxf.AddEntity(polyline8);

                //标注
                fun.jz(dxf, v27, 90, 3, "A");


                Text text1 = new Text(l1 + "", v1, height, 0);
                var l1_ = text1.Value.Length * height * 0.7;
                fun.dimrot1(dxf, v7, v24, 180, offset * 3, l1_, height, arrowsize, exline, "LS=" + l1, "", " ");// "+2", " 0");
                Text text2 = new Text(l3 + "", v1, height, 0);
                var l3_ = text2.Value.Length * height * 0.7 * 0.1;
                fun.dimrot1(dxf, v20, v24, 180, offset * 1.5, l3_, height, arrowsize, exline, "THLGTH=" + l3, "", "");// "+2", " 0");
                Text text3 = new Text(d + "", v1, height, 0);
                var arc2 = Pus.GetArcFromPline(polyline7, 1);
                var arc2Cen = Pus.ToV2(arc2.Center);
                var c1 = fun.Polar(arc2Cen, 90 * pi / 180, 0.174 * z / 2);
                if (d1 < 20)
                {
                    var d_ = text3.Value.Length * height * 0.7;
                    fun.dimrot1(dxf, v18, v23, -90, offset, d_ * 0.1, height, arrowsize, exline, "TD=" + d, "", ""); //" 0", "-0.1");
                    Text text5 = new Text(d2 + "", v1, height, 0);
                    var d2_ = text5.Value.Length * height * 0.7;
                    fun.Singlearrow(dxf, v36, 180, 5, -90, 25, arrowsize, exline, height, d2_ * 0.5, "d2=" + d2, "", "");// " 0", "-0.1");
                    fun.Singlearrow(dxf, c1, 180, 15, -90, 25, arrowsize, exline, height, d_ * 0.5, "TD=" + d, "", "");// " 0", "-0.1");
                }
                else
                {
                    var d_ = text3.Value.Length * height * 0.7 * 0.1;
                    fun.dimrot1(dxf, v18, v23, -90, offset, d_, height, arrowsize, exline, "TD=" + d, " ", "");//" 0", "-0.15");
                    Text text5 = new Text(d2 + "", v1, height, 0);
                    var d2_ = text5.Value.Length * height * 0.7;
                    fun.Singlearrow(dxf, v36, 180, 5, -90, 25, arrowsize, exline, height, d2_ * 0.5, "d2=" + d2, "", "");// " 0", "-0.15");
                    fun.Singlearrow(dxf, c1, 180, 15, -90, 25, arrowsize, exline, height, d_ * 0.5, "TD=" + d, "", "");//" 0", "-0.15");
                }

                Text text4 = new Text(d1 + "", v1, height, 0);
                var d1_ = text4.Value.Length * height * 0.7;
                fun.dimrot1(dxf, v15, v20, 90, offset * 0.3, d1_, height, arrowsize, exline, "DCONMS=" + d1, "", "");// "  ", "h8");

                fun.jdbz2(dxf, new Line(v31, v32), new Line(v31, v30), offset * 1.5, height, arrowsize, exline, "55°", " ", "");
                fun.jdbz2(dxf, new Line(v31, fun.Polar(v31, 90 * pi / 180, 0.1)), new Line(v31, v30), offset, height, arrowsize, exline, "27°30'", " ", "");
                fun.dimrot1(dxf, v31, v33, 0, offset * 2, 0, height, arrowsize, exline, "1.27(25.4/20)", "", "");


                var arc3 = Pus.GetArcFromPline(polyline7, 4);
                var arc3Cen = Pus.ToV2(arc3.Center);
                var c2 = fun.Polar(arc3Cen, -90 * pi / 180, 0.174 * z / 2);
                var arc4 = Pus.GetArcFromPline(polyline7, 5);
                var arc4Cen = Pus.ToV2(arc4.Center);
                var c3 = fun.Polar(arc4Cen, 90 * pi / 180, 0.174 * z / 2);
                fun.dimrot1(dxf, c2, c3, -90, offset, 0, height, arrowsize, exline, "0.813", "", "");
                fun.jt(dxf, c2, -45, 5, height, "R0.174");

                var circle1 = new Circle(v25, (v18.X - v16.X) * 0.2);
                dxf.AddEntity(circle1);
                fun.text(dxf, fun.Polar(fun.Polar(v25, 90 * pi / 180, (v18.X - v16.X) / 2), pi, height * 0.7 / 4), height, "Z");
                fun.text(dxf, fun.Polar(fun.Polar(v36p, 0 * pi / 180, (v37p.X - v36p.X) / 2), 90 * pi / 180, 25), height, "Z");

                var circle2 = new Circle(v26, (v19.Y - v24.Y) * 0.4);
                dxf.AddEntity(circle2);
                fun.text(dxf, fun.Polar(fun.Polar(v26, 0 * pi / 180, (v18.X - v16.X) / 2), pi, height * 0.7 / 4), height, "Y");



                //var s1 = "B 1.6/ 6.3";
                string[] s = Milling_cutter.MatchData(s1);
                var kx = s[0];

                //var D = Convert.ToDouble(s[1]) * z * 0.75;
                //double D1 = Convert.ToDouble(s[2]) * z * 0.75;

                if (kx.Equals("A"))
                {
                    var D3 = 1.6 * z * 0.75;
                    double D2 = 4 * z * 0.75;

                    var line9 = new Line(v1p, v0p);
                    line9.Layer = center;
                    line9.Lineweight = Lineweight.W25;
                    line9.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line9);

                    var v46 = fun.Polar(fun.Polar(v0p, pi, 1.5), 90 * pi / 180, D2 / 2);
                    var v47 = fun.mirrorpoint(v46, v0p, v1p);
                    var v49p = fun.Inters(v46, fun.Polar(v46, -150 * pi / 180, 1), v1p, v0p);
                    var v52 = fun.Polar(v49p, pi, D3 / 3);
                    var v50 = fun.Polar(v49p, 90 * pi / 180, D3 / 2);
                    var v51 = fun.mirrorpoint(v50, v1p, v0p);
                    var v49 = fun.Inters(v46, fun.Polar(v46, -150 * pi / 180, 1), v50, fun.Polar(v50, 0, 1));
                    var v48 = fun.mirrorpoint(v49, v1p, v0p);
                    var v38 = fun.Polar(v46, 90 * pi / 180, D2 / 2 * 2 / 3);
                    var v45 = fun.mirrorpoint(v38, v1p, v0p);
                    var polyline9 = Pus.AddPointsToLwPolyLine(v38, v46, v49, v50, v52, v51, v48, v47, v45);
                    fun.PolyFill(dxf, polyline9, 0.2, contour);
                    var line10 = new Line(v50, v51);
                    fun.drawBline(dxf, line10, 0.2, contour);
                    var line11 = new Line(v49, v48);
                    fun.drawBline(dxf, line11, 0.2, contour);
                    var line12 = new Line(v46, v47);
                    fun.drawBline(dxf, line12, 0.2, contour);
                    var v39 = fun.Polar(v38, 181 * pi / 180, 0.596 * D2);
                    var v40 = fun.Polar(v39, 180 * pi / 180, 0.342 * D2);
                    var v41 = fun.Polar(v40, 219 * pi / 180, 0.487 * D2);
                    var v42 = fun.Polar(v41, 264 * pi / 180, 0.797 * D2);
                    var v43 = fun.Polar(v42, 287 * pi / 180, 0.616 * D2);
                    var v44 = fun.Polar(v43, 353 * pi / 180, 0.344 * D2);
                    var v44p = fun.Polar(v44, 357 * pi / 180, 0.596 * D2);
                    var polyline10 = Pus.AddPointsToLwPolyLine(v38, v39, v40, v41, v42, v43, v44, v44p, v45);
                    polyline10.Vertexes[0].Bulge = Math.Tan(36 * Math.PI / 180 / 4);
                    polyline10.Vertexes[1].Bulge = Math.Tan(-25 * Math.PI / 180 / 4);
                    polyline10.Vertexes[2].Bulge = Math.Tan(93 * Math.PI / 180 / 4);
                    polyline10.Vertexes[3].Bulge = Math.Tan(-11 * Math.PI / 180 / 4);
                    polyline10.Vertexes[4].Bulge = Math.Tan(59 * Math.PI / 180 / 4);
                    polyline10.Vertexes[5].Bulge = Math.Tan(62 * Math.PI / 180 / 4);
                    polyline10.Vertexes[6].Bulge = Math.Tan(-45 * Math.PI / 180 / 4);
                    polyline10.Vertexes[7].Bulge = Math.Tan(34 * Math.PI / 180 / 4);
                    polyline10.Lineweight = Lineweight.W25;
                    polyline10.Layer = additionalline;
                    dxf.AddEntity(polyline10);

                    var polyline11 = Pus.AddPointsToLwPolyLine(v38, v39, v40, v41, v42, v43, v44, v44p, v45, v47, v48, v51, v52, v50, v49, v46, v38);
                    polyline11.Vertexes[0].Bulge = Math.Tan(36 * Math.PI / 180 / 4);
                    polyline11.Vertexes[1].Bulge = Math.Tan(-25 * Math.PI / 180 / 4);
                    polyline11.Vertexes[2].Bulge = Math.Tan(93 * Math.PI / 180 / 4);
                    polyline11.Vertexes[3].Bulge = Math.Tan(-11 * Math.PI / 180 / 4);
                    polyline11.Vertexes[4].Bulge = Math.Tan(59 * Math.PI / 180 / 4);
                    polyline11.Vertexes[5].Bulge = Math.Tan(62 * Math.PI / 180 / 4);
                    polyline11.Vertexes[6].Bulge = Math.Tan(-45 * Math.PI / 180 / 4);
                    polyline11.Vertexes[7].Bulge = Math.Tan(40 * Math.PI / 180 / 4);
                    String[] htype1 = new String[100];
                    Line[] hline1 = new Line[100];
                    Arc[] harc1 = new Arc[100];
                    int hnumst1 = polyline11.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst1; i++)
                    {
                        htype1[i] = polyline11.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype1[i] == "Line")
                        {
                            hline1[i] = (Line)polyline11.Explode()[i];
                        }
                        if (htype1[i] == "Arc")
                        {
                            harc1[i] = (Arc)polyline11.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);

                    fun.jdbz1(dxf, new Line(v49, v46), new Line(v48, v47), offset * 3, "60°", height);

                    fang.gcbz(dxf, fun.Polar(v47, -30 * pi / 180, 10), 10, -120, 5, 180, 7, arrowsize, 1, "A", "0.02", height, "ytd", 1);

                    fun.text(dxf, fun.Polar(fun.Polar(v1p, 0 * pi / 180, (v0p.X - v1p.X) / 2), 90 * pi / 180, 25), height, "Y");
                }
                if (kx.Equals("B"))
                {

                    var D3 = 1.6 * z * 0.75;
                    double D1 = 4 * z * 0.75;
                    double D2 = 5 * z * 0.75;

                    var line9 = new Line(v1p, v0p);
                    line9.Layer = center;
                    line9.Lineweight = Lineweight.W25;
                    line9.Linetype = Linetype.DashDot;
                    dxf.AddEntity(line9);

                    var v46 = fun.Polar(fun.Polar(v0p, pi, 1.5), 90 * pi / 180, D1 / 2);
                    var v47 = fun.mirrorpoint(v46, v0p, v1p);
                    var v49p = fun.Inters(v46, fun.Polar(v46, -150 * pi / 180, 1), v1p, v0p);
                    var v52 = fun.Polar(v49p, pi, D3 / 3);
                    var v50 = fun.Polar(v49p, 90 * pi / 180, D3 / 2);
                    var v51 = fun.mirrorpoint(v50, v1p, v0p);
                    var v49 = fun.Inters(v46, fun.Polar(v46, -150 * pi / 180, 1), v50, fun.Polar(v50, 0, 1));
                    var v48 = fun.mirrorpoint(v49, v1p, v0p);
                    var v38 = fun.Polar(v46, 90 * pi / 180, D1 / 2 * 2 / 3);
                    var v45 = fun.mirrorpoint(v38, v1p, v0p);
                    var v46p1 = fun.Polar(fun.Polar(v0p, pi, 1.5), 90 * pi / 180, D2 / 2);
                    var v46p2 = fun.Inters(v46, v49, v46p1, fun.Polar(v46p1, -120 * pi / 180, 1));
                    var v47p1 = fun.mirrorpoint(v46p1, v1p, v0p);
                    var v47p2 = fun.mirrorpoint(v46p2, v1p, v0p);
                    var polyline9 = Pus.AddPointsToLwPolyLine(v38, v46p1, v46p2, v49, v50, v52, v51, v48, v47p2, v47p1, v45);
                    fun.PolyFill(dxf, polyline9, 0.2, contour);
                    var line10 = new Line(v50, v51);
                    fun.drawBline(dxf, line10, 0.2, contour);
                    var line11 = new Line(v49, v48);
                    fun.drawBline(dxf, line11, 0.2, contour);
                    var line12 = new Line(v46p1, v47p1);
                    fun.drawBline(dxf, line12, 0.2, contour);
                    var v39 = fun.Polar(v38, 181 * pi / 180, 0.596 * D1);
                    var v40 = fun.Polar(v39, 180 * pi / 180, 0.342 * D1);
                    var v41 = fun.Polar(v40, 219 * pi / 180, 0.487 * D1);
                    var v42 = fun.Polar(v41, 264 * pi / 180, 0.797 * D1);
                    var v43 = fun.Polar(v42, 287 * pi / 180, 0.616 * D1);
                    var v44 = fun.Polar(v43, 353 * pi / 180, 0.344 * D1);
                    var v44p = fun.Polar(v44, 357 * pi / 180, 0.596 * D1);
                    var polyline10 = Pus.AddPointsToLwPolyLine(v38, v39, v40, v41, v42, v43, v44, v44p, v45);
                    polyline10.Vertexes[0].Bulge = Math.Tan(36 * Math.PI / 180 / 4);
                    polyline10.Vertexes[1].Bulge = Math.Tan(-25 * Math.PI / 180 / 4);
                    polyline10.Vertexes[2].Bulge = Math.Tan(93 * Math.PI / 180 / 4);
                    polyline10.Vertexes[3].Bulge = Math.Tan(-11 * Math.PI / 180 / 4);
                    polyline10.Vertexes[4].Bulge = Math.Tan(59 * Math.PI / 180 / 4);
                    polyline10.Vertexes[5].Bulge = Math.Tan(62 * Math.PI / 180 / 4);
                    polyline10.Vertexes[6].Bulge = Math.Tan(-45 * Math.PI / 180 / 4);
                    polyline10.Vertexes[7].Bulge = Math.Tan(34 * Math.PI / 180 / 4);
                    polyline10.Lineweight = Lineweight.W25;
                    polyline10.Layer = additionalline;
                    dxf.AddEntity(polyline10);


                    var polyline11 = Pus.AddPointsToLwPolyLine(v38, v39, v40, v41, v42, v43, v44, v44p, v45, v47p1, v47p2, v48, v51, v52, v50, v49, v46p2, v46p1, v38);
                    polyline11.Vertexes[0].Bulge = Math.Tan(36 * Math.PI / 180 / 4);
                    polyline11.Vertexes[1].Bulge = Math.Tan(-25 * Math.PI / 180 / 4);
                    polyline11.Vertexes[2].Bulge = Math.Tan(93 * Math.PI / 180 / 4);
                    polyline11.Vertexes[3].Bulge = Math.Tan(-11 * Math.PI / 180 / 4);
                    polyline11.Vertexes[4].Bulge = Math.Tan(59 * Math.PI / 180 / 4);
                    polyline11.Vertexes[5].Bulge = Math.Tan(62 * Math.PI / 180 / 4);
                    polyline11.Vertexes[6].Bulge = Math.Tan(-45 * Math.PI / 180 / 4);
                    polyline11.Vertexes[7].Bulge = Math.Tan(40 * Math.PI / 180 / 4);
                    String[] htype1 = new String[100];
                    Line[] hline1 = new Line[100];
                    Arc[] harc1 = new Arc[100];
                    int hnumst1 = polyline11.Explode().Count;  //记录爆炸后，线段有多少
                    for (int i = 0; i < hnumst1; i++)
                    {
                        htype1[i] = polyline11.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                        if (htype1[i] == "Line")
                        {
                            hline1[i] = (Line)polyline11.Explode()[i];
                        }
                        if (htype1[i] == "Arc")
                        {
                            harc1[i] = (Arc)polyline11.Explode()[i];
                        }
                    }
                    fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);

                    fun.jdbz1(dxf, new Line(v49, v46p2), new Line(v48, v47p2), offset * 3.2, "60°", height);
                    fun.jdbz1(dxf, new Line(v46p2, v46p1), new Line(v47p2, v47p1), offset * 4, "120°", height);

                    fang.gcbz(dxf, fun.Polar(v47, -30 * pi / 180, 10), 10, -120, 5, 180, 7, arrowsize, 1, "A", "0.02", height, "ytd", 1);

                    fun.text(dxf, fun.Polar(fun.Polar(v1p, 0 * pi / 180, (v0p.X - v1p.X) / 2), 90 * pi / 180, 25), height, "Y");
                }
            }
        }
        public static void Morsetapershank(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            //var msyz = 0;
            var msyz = Convert.ToDouble(data["msyz"]);

            if (msyz == 0)
            {  /*
                var zuidu = 1 / 19.212;
                var D1 = 9.2;
                var a = 3;
                var d = 6.4;
                var t = 4;
                var l2 = 53;*/


                var zuidu = Convert.ToDouble(data["zuidu"]);
                var D1 = Convert.ToDouble(data["d1ws"]);
                var d = Convert.ToDouble(data["d"]);
                var t = Convert.ToDouble(data["t"]);
                var l2 = Convert.ToDouble(data["l2"]);

                var v0 = new Vector2(0, 0);
                var v1 = fun.Polar(v0, 90 * pi / 180, D1 / 2);
                var v2 = new Vector2(v0.X + l2 - t, v0.Y + (D1 - zuidu * (l2 - t)) / 2);
                var v3 = fun.Polar(v2, -90 * pi / 180, 0.2 / 6.4 * d);
                var v4 = new Vector2(v0.X + l2, v3.Y);
                var v5 = fun.mirrorpoint(v4, v0, fun.Polar(v0, 0, 1));
                var v6 = fun.mirrorpoint(v3, v0, fun.Polar(v0, 0, 1));
                var v7 = fun.mirrorpoint(v2, v0, fun.Polar(v0, 0, 1));
                var v8 = fun.mirrorpoint(v1, v0, fun.Polar(v0, 0, 1));


                var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v7, v8, v1);
                fun.PolyFill(dxf, polyline1, 0.2, contour);
                var polyline2 = Pus.AddPointsToLwPolyLine(v3, v4, v5, v6);
                fun.PolyFill(dxf, polyline2, 0.2, contour);

            }
            else
            { /*
                var zuidu = 1 / 20.047;
                var D1 = 24.1;
                var d = 19.8;
                var d1 = 12.0;
                var d4 = 19.0;
                var d8 = 13.0;
                var d9 = 15.0;
                var d10 = 17.0;
                var l2 = 86.0;
                var l11 = 5.5;
                var t = 7.0;
                var i = 24.0;
                var bingxing = 2;
                var l4 = 18;
                var l3 = 12;
                var D = 23.825;
                var D2 = 36;*/
                var zuidu = Convert.ToDouble(data["zuidu"]);
                var D1 = Convert.ToDouble(data["d1ws"]);
                var d = Convert.ToDouble(data["dms"]);
                var d1 = Convert.ToDouble(data["d1ms"]);
                var d4 = Convert.ToDouble(data["d4"]);
                var d8 = Convert.ToDouble(data["d8"]);
                var d9 = Convert.ToDouble(data["d9"]);
                var d10 = Convert.ToDouble(data["d10"]);
                var l2 = Convert.ToDouble(data["l2"]);
                var l11 = Convert.ToDouble(data["l11"]);
                var t = Convert.ToDouble(data["t"]);
                var i = Convert.ToDouble(data["i"]);
                var bingxing = Convert.ToDouble(data["bingxing"]);
                var l4 = Convert.ToDouble(data["l4"]);
                var l3 = Convert.ToDouble(data["l3"]);
                var D = Convert.ToDouble(data["dws"]);
                var D2 = Convert.ToDouble(data["d2ws"]);


                if (bingxing == 2)
                {
                    var v0 = new Vector2(0 + l4, 0);
                    var v1 = fun.Polar(v0, 90 * pi / 180, D1 / 2);
                    var v2 = new Vector2(v0.X + l2 - t, v0.Y + (D1 - zuidu * (l2 - t)) / 2);
                    var v3 = new Vector2(v2.X, v0.Y + d4 / 2);
                    var v4 = new Vector2(v0.X + l2, v3.Y);
                    var v5 = fun.mirrorpoint(v4, v0, fun.Polar(v0, 0, 1));
                    var v6 = fun.mirrorpoint(v3, v0, fun.Polar(v0, 0, 1));
                    var v7 = fun.mirrorpoint(v2, v0, fun.Polar(v0, 0, 1));
                    var v8 = fun.mirrorpoint(v1, v0, fun.Polar(v0, 0, 1));
                    var v9 = fun.Polar(v0, 90 * pi / 180, D2 / 2);
                    var v10 = fun.Polar(v9, pi, l4);
                    var v11 = fun.Polar(v10, -90 * pi / 180, D2);
                    var v12 = fun.Polar(v11, 0, l4);
                    var v13 = fun.Polar(v0, 90 * pi / 180, D / 2);
                    var v14 = fun.Polar(v13, pi, l3);
                    var v15 = fun.Polar(v14, -90 * pi / 180, D);
                    var v16 = fun.Polar(v15, 0, l3);

                    var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v7, v8, v1);
                    fun.PolyFill(dxf, polyline1, 0.2, contour);
                    var polyline2 = Pus.AddPointsToLwPolyLine(v3, v4, v5, v6);
                    fun.PolyFill(dxf, polyline2, 0.2, contour);
                    var polyline5 = Pus.AddPointsToLwPolyLine(v9, v10, v11, v12, v9);
                    fun.PolyFill(dxf, polyline5, 0.2, contour);
                    var polyline6 = Pus.AddPointsToLwPolyLine(v13, v14, v15, v16, v13);
                    fun.PolyFill(dxf, polyline6, 0.2, contour);
                    var line6 = new Line(v13, v15);
                    fun.drawBline(dxf, line6, 0.2, contour);
                    var line7 = new Line(v14, v16);
                    fun.drawBline(dxf, line7, 0.2, contour);


                    var a0 = fun.Polar(v0, 0, l2);
                    var a1 = fun.Polar(a0, 90 * pi / 180, d10 / 2);
                    var a2p = fun.Polar(a0, 90 * pi / 180, d9 / 2);
                    var a2 = fun.Inters(a1, fun.Polar(a1, 240 * pi / 180, 1), a2p, fun.Polar(a2p, 0, 1));
                    var a3p = fun.Polar(a0, 90 * pi / 180, d8 / 2);
                    var a3 = fun.Inters(a2, fun.Polar(a2, 210 * pi / 180, 1), a3p, fun.Polar(a3p, 0, 1));
                    var a4 = new Vector2(a0.X - l11, a3.Y);
                    var a5p = fun.Polar(a0, 90 * pi / 180, 0.9 * d1 / 2);
                    var a5 = fun.Inters(a4, fun.Polar(a4, 225 * pi / 180, 1), a5p, fun.Polar(a5p, 0, 1));
                    var a6 = fun.Polar(a5, pi, 1.2 * (i - t));
                    var a7 = new Vector2(a6.X - 0.25 * (i - t), a0.Y);
                    var a6p = new Vector2(a0.X - i, a0.Y + d1 / 2);
                    var a5pp = fun.Inters(a6p, fun.Polar(a6p, pi, 1), a4, a5);
                    var a8 = fun.mirrorpoint(a6, a0, fun.Polar(a0, 0, 1));
                    var a9 = fun.mirrorpoint(a5, a0, fun.Polar(a0, 0, 1));
                    var a10 = fun.mirrorpoint(a4, a0, fun.Polar(a0, 0, 1));
                    var a11 = fun.mirrorpoint(a3, a0, fun.Polar(a0, 0, 1));
                    var a12 = fun.mirrorpoint(a2, a0, fun.Polar(a0, 0, 1));
                    var a13 = fun.mirrorpoint(a1, a0, fun.Polar(a0, 0, 1));
                    var a14 = fun.mirrorpoint(a6p, a0, fun.Polar(a0, 0, 1));
                    var a15 = fun.mirrorpoint(a5pp, a0, fun.Polar(a0, 0, 1));


                    var polyline3 = Pus.AddPointsToLwPolyLine(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13);
                    polyline3.Layer = refin;
                    polyline3.Lineweight = Lineweight.W35;
                    polyline3.Linetype = Linetype.Dashed;
                    dxf.AddEntity(polyline3);
                    var polyline4 = Pus.AddPointsToLwPolyLine(a5pp, a6p, a14, a15);
                    polyline4.Layer = refin;
                    polyline4.Lineweight = Lineweight.W35;
                    polyline4.Linetype = Linetype.Dashed;
                    dxf.AddEntity(polyline4);
                    Line line1 = new Line(a2, a12);
                    line1.Layer = refin;
                    line1.Lineweight = Lineweight.W35;
                    line1.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line1);
                    Line line2 = new Line(a3, a11);
                    line2.Layer = refin;
                    line2.Lineweight = Lineweight.W35;
                    line2.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line2);
                    Line line3 = new Line(a4, a10);
                    line3.Layer = refin;
                    line3.Lineweight = Lineweight.W35;
                    line3.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line3);
                    Line line4 = new Line(a5, a9);
                    line4.Layer = refin;
                    line4.Lineweight = Lineweight.W35;
                    line4.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line4);
                    Line line5 = new Line(a6, a8);
                    line5.Layer = refin;
                    line5.Lineweight = Lineweight.W35;
                    line5.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line5);
                }
                if (bingxing == 1)
                {
                    var v0 = new Vector2(0, 0);
                    var v1 = fun.Polar(v0, 90 * pi / 180, D1 / 2);
                    var v2 = new Vector2(v0.X + l2 - t, v0.Y + (D1 - zuidu * (l2 - t)) / 2);
                    var v3 = new Vector2(v2.X, v0.Y + d4 / 2);
                    var v4 = new Vector2(v0.X + l2, v3.Y);
                    var v5 = fun.mirrorpoint(v4, v0, fun.Polar(v0, 0, 1));
                    var v6 = fun.mirrorpoint(v3, v0, fun.Polar(v0, 0, 1));
                    var v7 = fun.mirrorpoint(v2, v0, fun.Polar(v0, 0, 1));
                    var v8 = fun.mirrorpoint(v1, v0, fun.Polar(v0, 0, 1));

                    var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v7, v8, v1);
                    fun.PolyFill(dxf, polyline1, 0.2, contour);
                    var polyline2 = Pus.AddPointsToLwPolyLine(v3, v4, v5, v6);
                    fun.PolyFill(dxf, polyline2, 0.2, contour);



                    var a0 = fun.Polar(v0, 0, l2);
                    var a1 = fun.Polar(a0, 90 * pi / 180, d10 / 2);
                    var a2p = fun.Polar(a0, 90 * pi / 180, d9 / 2);
                    var a2 = fun.Inters(a1, fun.Polar(a1, 240 * pi / 180, 1), a2p, fun.Polar(a2p, 0, 1));
                    var a3p = fun.Polar(a0, 90 * pi / 180, d8 / 2);
                    var a3 = fun.Inters(a2, fun.Polar(a2, 210 * pi / 180, 1), a3p, fun.Polar(a3p, 0, 1));
                    var a4 = new Vector2(a0.X - l11, a3.Y);
                    var a5p = fun.Polar(a0, 90 * pi / 180, 0.9 * d1 / 2);
                    var a5 = fun.Inters(a4, fun.Polar(a4, 225 * pi / 180, 1), a5p, fun.Polar(a5p, 0, 1));
                    var a6 = fun.Polar(a5, pi, 1.2 * (i - t));
                    var a7 = new Vector2(a6.X - 0.25 * (i - t), a0.Y);
                    var a6p = new Vector2(a0.X - i, a0.Y + d1 / 2);
                    var a5pp = fun.Inters(a6p, fun.Polar(a6p, pi, 1), a4, a5);
                    var a8 = fun.mirrorpoint(a6, a0, fun.Polar(a0, 0, 1));
                    var a9 = fun.mirrorpoint(a5, a0, fun.Polar(a0, 0, 1));
                    var a10 = fun.mirrorpoint(a4, a0, fun.Polar(a0, 0, 1));
                    var a11 = fun.mirrorpoint(a3, a0, fun.Polar(a0, 0, 1));
                    var a12 = fun.mirrorpoint(a2, a0, fun.Polar(a0, 0, 1));
                    var a13 = fun.mirrorpoint(a1, a0, fun.Polar(a0, 0, 1));
                    var a14 = fun.mirrorpoint(a6p, a0, fun.Polar(a0, 0, 1));
                    var a15 = fun.mirrorpoint(a5pp, a0, fun.Polar(a0, 0, 1));


                    var polyline3 = Pus.AddPointsToLwPolyLine(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13);
                    polyline3.Layer = refin;
                    polyline3.Lineweight = Lineweight.W35;
                    polyline3.Linetype = Linetype.Dashed;
                    dxf.AddEntity(polyline3);
                    var polyline4 = Pus.AddPointsToLwPolyLine(a5pp, a6p, a14, a15);
                    polyline4.Layer = refin;
                    polyline4.Lineweight = Lineweight.W35;
                    polyline4.Linetype = Linetype.Dashed;
                    dxf.AddEntity(polyline4);
                    Line line1 = new Line(a2, a12);
                    line1.Layer = refin;
                    line1.Lineweight = Lineweight.W35;
                    line1.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line1);
                    Line line2 = new Line(a3, a11);
                    line2.Layer = refin;
                    line2.Lineweight = Lineweight.W35;
                    line2.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line2);
                    Line line3 = new Line(a4, a10);
                    line3.Layer = refin;
                    line3.Lineweight = Lineweight.W35;
                    line3.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line3);
                    Line line4 = new Line(a5, a9);
                    line4.Layer = refin;
                    line4.Lineweight = Lineweight.W35;
                    line4.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line4);
                    Line line5 = new Line(a6, a8);
                    line5.Layer = refin;
                    line5.Lineweight = Lineweight.W35;
                    line5.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line5);
                }



            }


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);

            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Morse_tapershank(DxfDocument dxf, Vector2 hp1, double d0, double L, double l, double msyz, double bingxing)//msyz莫氏锥柄号，bingxing柄型 1为1型 2为2型，d0为切削直径
        {
            //DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            //string path = Convert.ToString(data["path"]);




            if (msyz == 0)
            {
                var zuidu = 1 / 19.212;
                var D1 = 9.2;
                var a = 3;
                var d = 6.4;
                var t = 4;
                var l2 = 53;
                var l3 = 56.5;
                var l4 = 59.5;

                double e;
                double b;
                double R;
                b = 3.9;
                R = 4;
                e = 10.5;




                if (bingxing == 0)
                {
                    var v1 = fun.Polar(hp1, 0, (L - l) - l3);
                    var v2 = fun.Polar(v1, 90 * pi / 180, D1 / 2);
                    var v3p = fun.Polar(v2, 0, l3 - e);
                    var v3 = fun.Polar(v3p, -90 * pi / 180, Math.Tan(a / 2 * pi / 180) * (l3 - e));


                    var ang = Math.Asin((R - (v3.Y - b / 2)) / R);
                    var c0 = new Vector2(v3.X + (Math.Sqrt(Math.Pow(R, 2) - Math.Pow(R - (v3.Y - b / 2), 2))), v1.Y + b / 2 + R);

                    var v4 = fun.Polar(c0, -90 * pi / 180, R);
                    var v5 = new Vector2(v4.X + e - (v4.X - v3.X) - b / 2, v4.Y);
                    var v6 = fun.mirrorpoint(v5, v1, fun.Polar(v1, 0, 1));
                    var v7 = fun.mirrorpoint(v4, v1, fun.Polar(v1, 0, 1));
                    var v8 = fun.mirrorpoint(v3, v1, fun.Polar(v1, 0, 1));
                    var v9 = fun.mirrorpoint(v2, v1, fun.Polar(v1, 0, 1));

                    var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v3, v4, v5, v6, v7, v8, v9, v2);
                    polyline1.Vertexes[2].Bulge = -Math.Tan((fun.CalAngle(c0, v3) - fun.CalAngle(c0, v4)) / 4);
                    polyline1.Vertexes[4].Bulge = -Math.Tan(180 * pi / 180 / 4);
                    polyline1.Vertexes[6].Bulge = -Math.Tan((fun.CalAngle(c0, v3) - fun.CalAngle(c0, v4)) / 4);
                    fun.PolyFill(dxf, polyline1, 0.2, contour);

                    var polyline2 = Pus.AddPointsToLwPolyLine(v4, v7);
                    fun.PolyFill(dxf, polyline2, 0.2, contour);

                    if (d0 <= D1)
                    {
                        var p0 = hp1;
                        var p1 = fun.Polar(p0, 90 * pi / 180, ((3.27 / 4.04 * d0) / 2));
                        var p2 = fun.Polar(p1, 0, L - l - l2 - l4);
                        var p3 = fun.Polar(p0, -90 * pi / 180, ((3.27 / 4.04 * d0) / 2));
                        var p4 = fun.Polar(p3, 0, L - l - l2 - l4);
                        var line01 = new Line(p1, p2);
                        fun.drawBline(dxf, line01, 0.2, contour);
                        var line02 = new Line(p3, p4);
                        fun.drawBline(dxf, line02, 0.2, contour);
                    }
                    else
                    {
                        var p0 = hp1;
                        var p1 = fun.Polar(p0, 90 * pi / 180, ((3.27 / 4.04 * D1) / 2));
                        var p2 = fun.Polar(p1, 0, L - l - l2 - l4);
                        var p3 = fun.Polar(p0, -90 * pi / 180, ((3.27 / 4.04 * D1) / 2));
                        var p4 = fun.Polar(p3, 0, L - l - l2 - l4);
                        var line01 = new Line(p1, p2);
                        fun.drawBline(dxf, line01, 0.2, contour);
                        var line02 = new Line(p3, p4);
                        fun.drawBline(dxf, line02, 0.2, contour);
                    }

                }
                else
                {
                    var v0 = fun.Polar(hp1, 0, L - l - l2);
                    var v1 = fun.Polar(v0, 90 * pi / 180, D1 / 2);
                    var v2 = new Vector2(v0.X + l2 - t, v0.Y + (D1 - zuidu * (l2 - t)) / 2);
                    var v3 = fun.Polar(v2, -90 * pi / 180, 0.2 / 6.4 * d);
                    var v4 = new Vector2(v0.X + l2, v3.Y);
                    var v5 = fun.mirrorpoint(v4, v0, fun.Polar(v0, 0, 1));
                    var v6 = fun.mirrorpoint(v3, v0, fun.Polar(v0, 0, 1));
                    var v7 = fun.mirrorpoint(v2, v0, fun.Polar(v0, 0, 1));
                    var v8 = fun.mirrorpoint(v1, v0, fun.Polar(v0, 0, 1));


                    var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v7, v8, v1);
                    fun.PolyFill(dxf, polyline1, 0.2, contour);
                    var polyline2 = Pus.AddPointsToLwPolyLine(v3, v4, v5, v6);
                    fun.PolyFill(dxf, polyline2, 0.2, contour);


                    var p0 = hp1;
                    var p1 = fun.Polar(p0, 90 * pi / 180, ((3.27 / 4.04 * d0) / 2));
                    var p2 = fun.Polar(p1, 0, L - l - l2);
                    var p3 = fun.Polar(p0, -90 * pi / 180, ((3.27 / 4.04 * d0) / 2));
                    var p4 = fun.Polar(p3, 0, L - l - l2);
                    var line01 = new Line(p1, p2);
                    fun.drawBline(dxf, line01, 0.2, contour);
                    var line02 = new Line(p3, p4);
                    fun.drawBline(dxf, line02, 0.2, contour);
                }

            }
            else
            {
                double zuidu;
                double D1;
                double d1;
                double d;
                double d4;
                double d8;
                double d9;
                double d10;
                double l2;
                double l11;
                double t;
                double i;
                double l4;
                double l3;
                double D;
                double D2;

                double e;
                double a;
                double b;
                double R;

                if (msyz == 1)
                {
                    zuidu = 1 / 20.047;
                    D1 = 12.2;
                    d1 = 6.0;
                    d4 = 9.0;
                    d8 = 6.4;
                    d9 = 8.0;
                    d10 = 8.5;
                    l2 = 57.0;
                    l11 = 4.0;
                    t = 5.0;
                    i = 16.0;
                    l4 = 0.0;
                    l3 = 62.0;
                    D = 12.065;
                    D2 = 0.0;
                    d = 9.4;
                    a = 3.5;
                    b = 5.2;
                    R = 5;
                    e = 13.5;
                }
                else if (msyz == 2)
                {
                    zuidu = 1 / 20.020;
                    D1 = 18;
                    d1 = 10.0;
                    d4 = 14.0;
                    d8 = 10.5;
                    d9 = 12.5;
                    d10 = 13.2;
                    l2 = 69.0;
                    l11 = 5.0;
                    t = 5.0;
                    i = 24.0;
                    l4 = 0.0;
                    l3 = 75.0;
                    D = 17.78;
                    D2 = 0.0;
                    d = 14.6;
                    a = 5;
                    b = 6.3;
                    R = 6;
                    e = 16;
                }
                else if (msyz == 3)
                {
                    zuidu = 1 / 19.922;
                    D1 = 24.1;
                    d1 = 12.0;
                    d4 = 19.0;
                    d8 = 13.0;
                    d9 = 15.0;
                    d10 = 17.0;
                    l2 = 86.0;
                    l11 = 5.5;
                    t = 7.0;
                    i = 24.0;
                    l4 = 18.0;
                    l3 = 94.0;
                    D = 23.825;
                    D2 = 36.0;
                    d = 19.8;
                    a = 5;
                    b = 7.9;
                    R = 7;
                    e = 20;
                }
                else if (msyz == 4)
                {
                    zuidu = 1 / 19.254;
                    D1 = 31.6;
                    d1 = 16.0;
                    d4 = 25.0;
                    d8 = 17.0;
                    d9 = 20.0;
                    d10 = 22.0;
                    l2 = 109.0;
                    l11 = 8.2;
                    t = 9.0;
                    i = 32.0;
                    l4 = 23.0;
                    l3 = 117.5;
                    D = 31.267;
                    D2 = 43.0;
                    d = 25.9;
                    a = 6.5;
                    b = 11.9;
                    R = 8;
                    e = 24;
                }
                else if (msyz == 5)
                {
                    zuidu = 1 / 19.002;
                    D1 = 44.7;
                    d1 = 20.0;
                    d4 = 35.7;
                    d8 = 21.0;
                    d9 = 26.0;
                    d10 = 30.0;
                    l2 = 136.0;
                    l11 = 10.0;
                    t = 10.0;
                    i = 40.0;
                    l4 = 28.0;
                    l3 = 149.5;
                    D = 44.399;
                    D2 = 60.0;
                    d = 37.6;
                    a = 6.5;
                    b = 15.9;
                    R = 12;
                    e = 29;

                }
                else if (msyz == 6)
                {
                    zuidu = 1 / 19.180;
                    D1 = 63.8;
                    d1 = 24.0;
                    d4 = 51.0;
                    d8 = 26.0;
                    d9 = 31.0;
                    d10 = 36.0;
                    l2 = 190.0;
                    l11 = 11.5;
                    t = 16.0;
                    i = 47.0;
                    l4 = 39.0;
                    l3 = 210.0;
                    D = 63.348;
                    D2 = 85.0;
                    d = 53.9;
                    a = 8;
                    b = 19;
                    R = 18;
                    e = 40;
                }
                else
                {
                    zuidu = 1 / 19.180;
                    D1 = 63.8;
                    d1 = 24.0;
                    d4 = 51.0;
                    d8 = 26.0;
                    d9 = 31.0;
                    d10 = 36.0;
                    l2 = 190.0;
                    l11 = 11.5;
                    t = 16.0;
                    i = 47.0;
                    l4 = 39.0;
                    l3 = 25.0;
                    D = 63.348;
                    D2 = 85.0;
                    d = 53.9;
                    a = 6.5;
                    b = 11.9;
                    R = 8;
                    e = 24;
                }

                if (bingxing == 0) //带扁尾的莫氏锥柄
                {
                    var v1 = fun.Polar(hp1, 0, L - l - l3 - a);
                    var v2 = fun.Polar(v1, 90 * pi / 180, D1 / 2);
                    var v3p = fun.Polar(v2, 0, l3 + a - e);
                    var v3 = fun.Polar(v3p, -90 * pi / 180, Math.Tan(a / 2 * pi / 180) * (l3 - e));


                    var ang = Math.Asin((R - (v3.Y - b / 2)) / R);
                    var c0 = new Vector2(v3.X + (Math.Sqrt(Math.Pow(R, 2) - Math.Pow(R - (v3.Y - b / 2), 2))), v1.Y + b / 2 + R);

                    var v4 = fun.Polar(c0, -90 * pi / 180, R);
                    var v5 = new Vector2(v4.X + e - (v4.X - v3.X) - b / 2, v4.Y);
                    var v6 = fun.mirrorpoint(v5, v1, fun.Polar(v1, 0, 1));
                    var v7 = fun.mirrorpoint(v4, v1, fun.Polar(v1, 0, 1));
                    var v8 = fun.mirrorpoint(v3, v1, fun.Polar(v1, 0, 1));
                    var v9 = fun.mirrorpoint(v2, v1, fun.Polar(v1, 0, 1));

                    var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v3, v4, v5, v6, v7, v8, v9, v2);
                    polyline1.Vertexes[2].Bulge = -Math.Tan((fun.CalAngle(c0, v3) - fun.CalAngle(c0, v4)) / 4);
                    polyline1.Vertexes[4].Bulge = -Math.Tan(180 * pi / 180 / 4);
                    polyline1.Vertexes[6].Bulge = -Math.Tan((fun.CalAngle(c0, v3) - fun.CalAngle(c0, v4)) / 4);
                    fun.PolyFill(dxf, polyline1, 0.2, contour);

                    var polyline2 = Pus.AddPointsToLwPolyLine(v4, v7);
                    fun.PolyFill(dxf, polyline2, 0.2, contour);
                    Vector2 p100 = fun.Polar(hp1, 0, L - l - R / 2 - 1);
                    Vector2 p101 = fun.Polar(p100, pi, L - 2.74);







                    if (d0 <= D1)
                    {
                        var p0 = hp1;
                        var p1 = fun.Polar(p0, 90 * pi / 180, ((3.27 / 4.04 * d0) / 2));
                        var p2 = fun.Polar(p1, 0, L - l - l3 - a);
                        var p3 = fun.Polar(p0, -90 * pi / 180, ((3.27 / 4.04 * d0) / 2));
                        var p4 = fun.Polar(p3, 0, L - l - l3 - a);
                        var line01 = new Line(p1, p2);
                        fun.drawBline(dxf, line01, 0.2, contour);
                        var line02 = new Line(p3, p4);
                        fun.drawBline(dxf, line02, 0.2, contour);
                    }
                    else
                    {
                        var p0 = hp1;
                        var p1 = fun.Polar(p0, 90 * pi / 180, ((3.27 / 4.04 * D1) / 2));
                        var p2 = fun.Polar(p1, 0, L - l - l3 - a);
                        var p3 = fun.Polar(p0, -90 * pi / 180, ((3.27 / 4.04 * D1) / 2));
                        var p4 = fun.Polar(p3, 0, L - l - l3 - a);
                        var line01 = new Line(p1, p2);
                        fun.drawBline(dxf, line01, 0.2, contour);
                        var line02 = new Line(p3, p4);
                        fun.drawBline(dxf, line02, 0.2, contour);
                    }

                }

                if (bingxing == 2)//带螺纹孔的Ⅱ型莫氏锥柄
                {
                    var v0 = fun.Polar(hp1, 0, L - l - l2);
                    var v1 = fun.Polar(v0, 90 * pi / 180, D1 / 2);
                    var v2 = new Vector2(v0.X + l2 - t, v0.Y + d / 2);
                    var v3 = new Vector2(v2.X, v0.Y + d4 / 2);
                    var v4 = new Vector2(v0.X + l2, v3.Y);
                    var v5 = fun.mirrorpoint(v4, v0, fun.Polar(v0, 0, 1));
                    var v6 = fun.mirrorpoint(v3, v0, fun.Polar(v0, 0, 1));
                    var v7 = fun.mirrorpoint(v2, v0, fun.Polar(v0, 0, 1));
                    var v8 = fun.mirrorpoint(v1, v0, fun.Polar(v0, 0, 1));
                    var v9 = fun.Polar(v0, 90 * pi / 180, D2 / 2);
                    var v10 = fun.Polar(v9, pi, l4);
                    var v11 = fun.Polar(v10, -90 * pi / 180, D2);
                    var v12 = fun.Polar(v11, 0, l4);
                    var v13 = fun.Polar(v0, 90 * pi / 180, D / 2);
                    var v14 = fun.Polar(v13, pi, l3);
                    var v15 = fun.Polar(v14, -90 * pi / 180, D);
                    var v16 = fun.Polar(v15, 0, l3);

                    var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v7, v8, v1);
                    fun.PolyFill(dxf, polyline1, 0.2, contour);
                    var polyline2 = Pus.AddPointsToLwPolyLine(v3, v4, v5, v6);
                    fun.PolyFill(dxf, polyline2, 0.2, contour);
                    var polyline5 = Pus.AddPointsToLwPolyLine(v9, v10, v11, v12, v9);
                    fun.PolyFill(dxf, polyline5, 0.2, contour);
                    var polyline6 = Pus.AddPointsToLwPolyLine(v13, v14, v15, v16, v13);
                    fun.PolyFill(dxf, polyline6, 0.2, contour);
                    var line6 = new Line(v13, v15);
                    fun.drawBline(dxf, line6, 0.2, contour);
                    var line7 = new Line(v14, v16);
                    fun.drawBline(dxf, line7, 0.2, contour);


                    var a0 = fun.Polar(v0, 0, l2);
                    var a1 = fun.Polar(a0, 90 * pi / 180, d10 / 2);
                    var a2p = fun.Polar(a0, 90 * pi / 180, d9 / 2);
                    var a2 = fun.Inters(a1, fun.Polar(a1, 240 * pi / 180, 1), a2p, fun.Polar(a2p, 0, 1));
                    var a3p = fun.Polar(a0, 90 * pi / 180, d8 / 2);
                    var a3 = fun.Inters(a2, fun.Polar(a2, 210 * pi / 180, 1), a3p, fun.Polar(a3p, 0, 1));
                    var a4 = new Vector2(a0.X - l11, a3.Y);
                    var a5p = fun.Polar(a0, 90 * pi / 180, 0.9 * d1 / 2);
                    var a5 = fun.Inters(a4, fun.Polar(a4, 225 * pi / 180, 1), a5p, fun.Polar(a5p, 0, 1));
                    var a6 = fun.Polar(a5, pi, 1.2 * (i - t));
                    var a7 = new Vector2(a6.X - 0.25 * (i - t), a0.Y);
                    var a6p = new Vector2(a0.X - i, a0.Y + d1 / 2);
                    var a5pp = fun.Inters(a6p, fun.Polar(a6p, pi, 1), a4, a5);
                    var a8 = fun.mirrorpoint(a6, a0, fun.Polar(a0, 0, 1));
                    var a9 = fun.mirrorpoint(a5, a0, fun.Polar(a0, 0, 1));
                    var a10 = fun.mirrorpoint(a4, a0, fun.Polar(a0, 0, 1));
                    var a11 = fun.mirrorpoint(a3, a0, fun.Polar(a0, 0, 1));
                    var a12 = fun.mirrorpoint(a2, a0, fun.Polar(a0, 0, 1));
                    var a13 = fun.mirrorpoint(a1, a0, fun.Polar(a0, 0, 1));
                    var a14 = fun.mirrorpoint(a6p, a0, fun.Polar(a0, 0, 1));
                    var a15 = fun.mirrorpoint(a5pp, a0, fun.Polar(a0, 0, 1));


                    var polyline3 = Pus.AddPointsToLwPolyLine(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13);
                    polyline3.Layer = refin;
                    polyline3.Lineweight = Lineweight.W35;
                    polyline3.Linetype = Linetype.Dashed;
                    dxf.AddEntity(polyline3);
                    var polyline4 = Pus.AddPointsToLwPolyLine(a5pp, a6p, a14, a15);
                    polyline4.Layer = refin;
                    polyline4.Lineweight = Lineweight.W35;
                    polyline4.Linetype = Linetype.Dashed;
                    dxf.AddEntity(polyline4);
                    Line line1 = new Line(a2, a12);
                    line1.Layer = refin;
                    line1.Lineweight = Lineweight.W35;
                    line1.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line1);
                    Line line2 = new Line(a3, a11);
                    line2.Layer = refin;
                    line2.Lineweight = Lineweight.W35;
                    line2.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line2);
                    Line line3 = new Line(a4, a10);
                    line3.Layer = refin;
                    line3.Lineweight = Lineweight.W35;
                    line3.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line3);
                    Line line4 = new Line(a5, a9);
                    line4.Layer = refin;
                    line4.Lineweight = Lineweight.W35;
                    line4.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line4);
                    Line line5 = new Line(a6, a8);
                    line5.Layer = refin;
                    line5.Lineweight = Lineweight.W35;
                    line5.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line5);

                    if (d0 <= D1)
                    {
                        var p0 = hp1;
                        var p1 = fun.Polar(p0, 90 * pi / 180, ((3.27 / 4.04 * d0) / 2));
                        var p2 = fun.Polar(p1, 0, L - l - l2 - l4);
                        var p3 = fun.Polar(p0, -90 * pi / 180, ((3.27 / 4.04 * d0) / 2));
                        var p4 = fun.Polar(p3, 0, L - l - l2 - l4);
                        var line01 = new Line(p1, p2);
                        fun.drawBline(dxf, line01, 0.2, contour);
                        var line02 = new Line(p3, p4);
                        fun.drawBline(dxf, line02, 0.2, contour);
                    }
                    else
                    {
                        var p0 = hp1;
                        var p1 = fun.Polar(p0, 90 * pi / 180, ((3.27 / 4.04 * D1) / 2));
                        var p2 = fun.Polar(p1, 0, L - l - l2 - l4);
                        var p3 = fun.Polar(p0, -90 * pi / 180, ((3.27 / 4.04 * D1) / 2));
                        var p4 = fun.Polar(p3, 0, L - l - l2 - l4);
                        var line01 = new Line(p1, p2);
                        fun.drawBline(dxf, line01, 0.2, contour);
                        var line02 = new Line(p3, p4);
                        fun.drawBline(dxf, line02, 0.2, contour);
                    }

                }
                if (bingxing == 1)//带螺纹孔的Ⅰ型莫氏锥柄
                {
                    var v0 = fun.Polar(hp1, 0, L - l - l2);
                    var v1 = fun.Polar(v0, 90 * pi / 180, D1 / 2);
                    var v2 = new Vector2(v0.X + l2 - t, v0.Y + d / 2);
                    var v3 = new Vector2(v2.X, v0.Y + d4 / 2);
                    var v4 = new Vector2(v0.X + l2, v3.Y);
                    var v5 = fun.mirrorpoint(v4, v0, fun.Polar(v0, 0, 1));
                    var v6 = fun.mirrorpoint(v3, v0, fun.Polar(v0, 0, 1));
                    var v7 = fun.mirrorpoint(v2, v0, fun.Polar(v0, 0, 1));
                    var v8 = fun.mirrorpoint(v1, v0, fun.Polar(v0, 0, 1));

                    var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v7, v8, v1);
                    fun.PolyFill(dxf, polyline1, 0.2, contour);
                    var polyline2 = Pus.AddPointsToLwPolyLine(v3, v4, v5, v6);
                    fun.PolyFill(dxf, polyline2, 0.2, contour);



                    var a0 = fun.Polar(v0, 0, l2);
                    var a1 = fun.Polar(a0, 90 * pi / 180, d10 / 2);
                    var a2p = fun.Polar(a0, 90 * pi / 180, d9 / 2);
                    var a2 = fun.Inters(a1, fun.Polar(a1, 240 * pi / 180, 1), a2p, fun.Polar(a2p, 0, 1));
                    var a3p = fun.Polar(a0, 90 * pi / 180, d8 / 2);
                    var a3 = fun.Inters(a2, fun.Polar(a2, 210 * pi / 180, 1), a3p, fun.Polar(a3p, 0, 1));
                    var a4 = new Vector2(a0.X - l11, a3.Y);
                    var a5p = fun.Polar(a0, 90 * pi / 180, 0.9 * d1 / 2);
                    var a5 = fun.Inters(a4, fun.Polar(a4, 225 * pi / 180, 1), a5p, fun.Polar(a5p, 0, 1));
                    var a6 = fun.Polar(a5, pi, 1.2 * (i - t));
                    var a7 = new Vector2(a6.X - 0.25 * (i - t), a0.Y);
                    var a6p = new Vector2(a0.X - i, a0.Y + d1 / 2);
                    var a5pp = fun.Inters(a6p, fun.Polar(a6p, pi, 1), a4, a5);
                    var a8 = fun.mirrorpoint(a6, a0, fun.Polar(a0, 0, 1));
                    var a9 = fun.mirrorpoint(a5, a0, fun.Polar(a0, 0, 1));
                    var a10 = fun.mirrorpoint(a4, a0, fun.Polar(a0, 0, 1));
                    var a11 = fun.mirrorpoint(a3, a0, fun.Polar(a0, 0, 1));
                    var a12 = fun.mirrorpoint(a2, a0, fun.Polar(a0, 0, 1));
                    var a13 = fun.mirrorpoint(a1, a0, fun.Polar(a0, 0, 1));
                    var a14 = fun.mirrorpoint(a6p, a0, fun.Polar(a0, 0, 1));
                    var a15 = fun.mirrorpoint(a5pp, a0, fun.Polar(a0, 0, 1));


                    var polyline3 = Pus.AddPointsToLwPolyLine(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13);
                    polyline3.Layer = refin;
                    polyline3.Lineweight = Lineweight.W35;
                    polyline3.Linetype = Linetype.Dashed;
                    dxf.AddEntity(polyline3);
                    var polyline4 = Pus.AddPointsToLwPolyLine(a5pp, a6p, a14, a15);
                    polyline4.Layer = refin;
                    polyline4.Lineweight = Lineweight.W35;
                    polyline4.Linetype = Linetype.Dashed;
                    dxf.AddEntity(polyline4);
                    Line line1 = new Line(a2, a12);
                    line1.Layer = refin;
                    line1.Lineweight = Lineweight.W35;
                    line1.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line1);
                    Line line2 = new Line(a3, a11);
                    line2.Layer = refin;
                    line2.Lineweight = Lineweight.W35;
                    line2.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line2);
                    Line line3 = new Line(a4, a10);
                    line3.Layer = refin;
                    line3.Lineweight = Lineweight.W35;
                    line3.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line3);
                    Line line4 = new Line(a5, a9);
                    line4.Layer = refin;
                    line4.Lineweight = Lineweight.W35;
                    line4.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line4);
                    Line line5 = new Line(a6, a8);
                    line5.Layer = refin;
                    line5.Lineweight = Lineweight.W35;
                    line5.Linetype = Linetype.Dashed;
                    dxf.AddEntity(line5);


                    if (d0 <= D)
                    {
                        var p0 = hp1;
                        var p1 = fun.Polar(p0, 90 * pi / 180, ((3.27 / 4.04 * d0) / 2));
                        var p2 = fun.Polar(p1, 0, L - l - l2);
                        var p3 = fun.Polar(p0, -90 * pi / 180, ((3.27 / 4.04 * d0) / 2));
                        var p4 = fun.Polar(p3, 0, L - l - l2);
                        var line01 = new Line(p1, p2);
                        fun.drawBline(dxf, line01, 0.2, contour);
                        var line02 = new Line(p3, p4);
                        fun.drawBline(dxf, line02, 0.2, contour);
                    }
                    else
                    {
                        var p0 = hp1;
                        var p1 = fun.Polar(p0, 90 * pi / 180, ((3.27 / 4.04 * D) / 2));
                        var p2 = fun.Polar(p1, 0, L - l - l2);
                        var p3 = fun.Polar(p0, -90 * pi / 180, ((3.27 / 4.04 * D) / 2));
                        var p4 = fun.Polar(p3, 0, L - l - l2);
                        var line01 = new Line(p1, p2);
                        fun.drawBline(dxf, line01, 0.2, contour);
                        var line02 = new Line(p3, p4);
                        fun.drawBline(dxf, line02, 0.2, contour);


                    }
                }

            }

        }

        public static void Millingcutterswithparallelshanks(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            //var d = 8;
            //var d1 = 8;
            //var l = 16;
            //var L = 60;
            //var bbxz = 2;

            var d = 8.0;//切削直径
            try
            {
                d = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var d1 = 8.0;//机床测连接直径
            try
            {
                d1 = Convert.ToDouble(data["dconms"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var l = 16.0;//最大切削深度
            try
            {
                l = Convert.ToDouble(data["apmx"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l] not found");
            }
            var L = 60.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var bbxz = 0.0;//铣刀柄部型式
            try
            {
                bbxz = Convert.ToDouble(data["bbxz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bbxz] not found");
            }

            //坐标

            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, 90 * pi / 180, d / 2);
            var v2 = fun.Polar(v1, 0, l);
            var v3 = fun.Polar(v2, -90 * pi / 180, d);
            var v4 = fun.Polar(v3, pi, l);
            var v5 = fun.Polar(v0, 0, l);

            var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v3, v4, v1);
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            //dxf.AddEntity(polyline1);





            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = polyline1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = polyline1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)polyline1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)polyline1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, -20, fun.CalDistance(v1, v3) * 1.25, hline1, harc1, contour);



            var line1 = new Line(fun.Polar(v0, pi, 5), fun.Polar(v0, 0, L + 5));
            line1.Layer = centre;
            line1.Lineweight = Lineweight.W25;
            line1.Linetype = Linetype.DashDot;
            dxf.AddEntity(line1);

            var a1 = v0;
            var a2 = fun.Polar(a1, -90 * pi / 180, 0.084 * d);
            var a3 = fun.Inters(a1, fun.Polar(a1, -18 * pi / 180, 1), v4, v3);
            var a4 = fun.Inters(a2, fun.Polar(a2, -18 * pi / 180, 1), v4, v3);
            var a5 = fun.Polar(a1, 90 * pi / 180, 0.383 * d);
            var a6 = fun.Inters(a5, fun.Polar(a5, -18 * pi / 180, 1), v2, v3);
            var a7 = fun.Polar(a5, -90 * pi / 180, 0.084 * d);
            var a8 = fun.Inters(a7, fun.Polar(a7, -18 * pi / 180, 1), v2, v3);
            var a9 = fun.Polar(a5, 90 * pi / 180, 0.383 * d);
            var a10 = fun.Inters(a9, fun.Polar(a9, -18 * pi / 180, 1), v2, v3);
            var a11 = fun.Polar(a9, -90 * pi / 180, 0.084 * d);
            var a12 = fun.Inters(a11, fun.Polar(a11, -18 * pi / 180, 1), v2, v3);
            var a13 = fun.Inters(a9, a10, v1, v2);
            var a14 = fun.Inters(a11, a12, v1, v2);

            /*
                        var line2 = new Line(a1, a3);
                        line2.Layer = additionalline;
                        line2.Lineweight = Lineweight.W25;
                        dxf.AddEntity(line2);
                        var line3 = new Line(a2, a4);
                        line3.Layer = additionalline;
                        line3.Lineweight = Lineweight.W25;
                        dxf.AddEntity(line3);
                        var line4 = new Line(a5, a6);
                        line4.Layer = additionalline;
                        line4.Lineweight = Lineweight.W25;
                        dxf.AddEntity(line4);
                        var line5 = new Line(a7, a8);
                        line5.Layer = additionalline;
                        line5.Lineweight = Lineweight.W25;
                        dxf.AddEntity(line5);
                        var line6 = new Line(a13, a10);
                        line6.Layer = additionalline;
                        line6.Lineweight = Lineweight.W25;
                        dxf.AddEntity(line6);
                        var line7 = new Line(a14, a12);
                        line7.Layer = additionalline;
                        line7.Lineweight = Lineweight.W25;
                        dxf.AddEntity(line7);*/

            Milling_cutter.Milling_shankDictionary(dxf, v5, d1, bbxz, L, l, d,data);

            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度


            fun.dimrot1(dxf, v1, v4, 90, offset, 0, height, arrowsize, exline, "DC=" + d, "", "");
            fun.dimrot1(dxf, v3, v4, 180, offset, 0, height, arrowsize, exline, "APMX=" + l, "", "");
            fun.dimrot1(dxf, new Vector2(v0.X + L, v0.Y - d1 / 2), v4, 180, offset * 2, 0, height, arrowsize, exline, "OAL=" + L, "", "");


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);

            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Keywaycutters1(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /* var d = 6;
             var d1 = 6;
             var l = 13;
             var L = 57;
             var bbxz = 0;*/

            var d = 6.0;//切削直径
            try
            {
                d = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var d1 = 6.0;//机床测连接直径
            try
            {
                d1 = Convert.ToDouble(data["dconms"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var l = 13.0;//最大切削深度
            try
            {
                l = Convert.ToDouble(data["apmx"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l] not found");
            }
            var L = 57.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var bbxz = 0.0;//铣刀柄部型式
            try
            {
                bbxz = Convert.ToDouble(data["bbxz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bbxz] not found");
            }

            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, 90 * pi / 180, d / 2);
            var v2 = fun.Polar(v1, 0, l);
            var v3 = fun.Polar(v2, -90 * pi / 180, d);
            var v4 = fun.Polar(v3, pi, l);
            var v5 = fun.Polar(v0, 0, 0.084 * l);
            var v6 = fun.Polar(v0, 90 * pi / 180, 0.122 * d);
            var v7 = fun.Polar(v0, -90 * pi / 180, 0.122 * d);
            var v8p = fun.Polar(v3, 90 * pi / 180, (0.77 / 4.04 * d) / 2);
            var v8 = fun.Polar(v8p, 0, 0.205 * l);

            var line1 = new Line(fun.Polar(v0, pi, 5), fun.Polar(v0, 0, L + 5));
            line1.Layer = centre;
            line1.Lineweight = Lineweight.W25;
            line1.Linetype = Linetype.DashDot;
            dxf.AddEntity(line1);

            var polyline1 = Pus.AddPointsToLwPolyLine(v5, v6, v1, v2, fun.Polar(v2, -90 * pi / 180, (0.77 / 4.04 * d) / 2));
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            var polyline4 = Pus.AddPointsToLwPolyLine(v8p, v3, v4, v7);
            fun.PolyFill(dxf, polyline4, 0.2, contour);
            var polyline2 = Pus.AddPointsToLwPolyLine(v1, v7);
            polyline2.Vertexes[0].Bulge = Math.Tan(-145 * Math.PI / 180 / 4);
            fun.PolyFill(dxf, polyline2, 0.2, contour);
            var polyline3 = Pus.AddPointsToLwPolyLine(v5, v8);
            polyline3.Vertexes[0].Bulge = Math.Tan(-41 * Math.PI / 180 / 4);
            fun.PolyFill(dxf, polyline3, 0.2, contour);




            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度



            fun.dimrot1(dxf, v1, v4, 90, offset, 0, height, arrowsize, exline, "DC=" + d, "", "");
            fun.dimrot1(dxf, v3, v4, 180, offset, 0, height, arrowsize, exline, "APMX=" + l, "", "");
            fun.dimrot1(dxf, new Vector2(v0.X + L, v0.Y - d1 / 2), v4, 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");




            Milling_cutter.Milling_shankDictionary(dxf, fun.Polar(v0, 0, l), d1, bbxz, L, l, d,data);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Keywaycutters2(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /* var d = 6;
             var d1 = 6;
             var l = 13;
             var L = 57;
             var bbxz = 0;*/

            var d = 32.0;//切削直径
            try
            {
                d = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }/*
            var d1 = 6.0;//机床测连接直径
            try
            {
                d1 = Convert.ToDouble(data["dconms"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }*/
            var l = 32.0;//最大切削深度
            try
            {
                l = Convert.ToDouble(data["apmx"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l] not found");
            }
            var L = 180.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var msyz = 4.0;//莫氏锥柄号
            try
            {
                msyz = Convert.ToDouble(data["msyz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[msyz] not found");
            }
            var bingxing = 1.0;//铣刀柄部型式
            try
            {
                bingxing = Convert.ToDouble(data["bingxing"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bingxing] not found");
            }

            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, 90 * pi / 180, d / 2);
            var v2 = fun.Polar(v1, 0, l);
            var v3 = fun.Polar(v2, -90 * pi / 180, d);
            var v4 = fun.Polar(v3, pi, l);
            var v5 = fun.Polar(v0, 0, 0.084 * l);
            var v6 = fun.Polar(v0, 90 * pi / 180, 0.122 * d);
            var v7 = fun.Polar(v0, -90 * pi / 180, 0.122 * d);
            var v8p = fun.Polar(v3, 90 * pi / 180, (0.77 / 4.04 * d) / 2);
            var v8 = fun.Polar(v8p, 0, 0.205 * l);

            var line1 = new Line(fun.Polar(v0, pi, 5), fun.Polar(v0, 0, L + 5));
            line1.Layer = centre;
            line1.Lineweight = Lineweight.W25;
            line1.Linetype = Linetype.DashDot;
            dxf.AddEntity(line1);

            var polyline1 = Pus.AddPointsToLwPolyLine(v5, v6, v1, v2, fun.Polar(v2, -90 * pi / 180, (0.77 / 4.04 * d) / 2));
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            var polyline4 = Pus.AddPointsToLwPolyLine(v8p, v3, v4, v7);
            fun.PolyFill(dxf, polyline4, 0.2, contour);
            var polyline2 = Pus.AddPointsToLwPolyLine(v1, v7);
            polyline2.Vertexes[0].Bulge = Math.Tan(-145 * Math.PI / 180 / 4);
            fun.PolyFill(dxf, polyline2, 0.2, contour);
            var polyline3 = Pus.AddPointsToLwPolyLine(v5, v8);
            polyline3.Vertexes[0].Bulge = Math.Tan(-41 * Math.PI / 180 / 4);
            fun.PolyFill(dxf, polyline3, 0.2, contour);




            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度



            fun.dimrot1(dxf, v1, v4, 90, offset, 0, height, arrowsize, exline, "DC=" + d, "", "");
            fun.dimrot1(dxf, v3, v4, 180, offset, 0, height, arrowsize, exline, "APMX=" + l, "", "");
            fun.dimrot1(dxf, new Vector2(v0.X + L, v0.Y), v4, 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");



            Milling_cutter.Morse_tapershank(dxf, fun.Polar(v0, 0, l), d, L, l, msyz, bingxing);//锥柄号，柄型


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard20773_1to2(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            var d1 = 4.0;//切削直径
            try
            {
                d1 = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var d2 = 4.0;//连接直径
            try
            {
                d2 = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d2] not found");
            }
            var l = 11.0;//最大切削深度
            try
            {
                l = Convert.ToDouble(data["apmx"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l] not found");
            }
            var L = 43.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var bbxz = 0.0;//柄部型式
            try
            {
                bbxz = Convert.ToDouble(data["bbxz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bbxz] not found");
            }

            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, 90 * pi / 180, d1 / 2);
            var v2 = fun.Polar(v1, pi, l - d1 / 2);
            var v3 = fun.Polar(v0, pi, l);
            var v4 = fun.mirrorpoint(v2, v0, v3);
            var v5 = fun.mirrorpoint(v1, v0, v3);

            var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v4, v5, v1);
            polyline1.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);


            Milling_cutter.Milling_shankDictionary(dxf, v0, d2, bbxz, L, l, d1,data);


            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度

            var a1 = fun.Polar(v0, pi, l);
            var a2 = fun.Polar(a1, 0, L);
            var a3 = fun.Polar(a1, pi, d1 / 2);
            var a4 = fun.Polar(a2, 0, d1 / 2);
            Line line00 = new Line(a3, a4);
            line00.Layer = centre;
            line00.Lineweight = Lineweight.W25;
            line00.Linetype = Linetype.DashDot;
            dxf.AddEntity(line00);


            fun.dimrot1(dxf, v2, v4, 90, offset, 0, height, arrowsize, exline, "DC=" + d1, "", "");
            fun.dimrot1(dxf, v3, v5, 180, offset * 1.25, 0, height, arrowsize, exline, "APMX=" + l, "", "");
            fun.dimrot1(dxf, new Vector2(v0.X + L - l, v0.Y), v3, 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard20773_3(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /*var d1 = 16;
            var l = 32;
            var L = 117;
            var msyz = 2.0;
            var bingxing = 1.0;*/

            var d1 = 16.0;//切削直径
            try
            {
                d1 = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var l = 32.0;//最大切削深度
            try
            {
                l = Convert.ToDouble(data["apmx"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l] not found");
            }
            var L = 117.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var msyz = 2.0;//莫氏锥柄号
            try
            {
                msyz = Convert.ToDouble(data["msyz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[msyz] not found");
            }
            var bingxing = 1.0;//柄型
            try
            {
                bingxing = Convert.ToDouble(data["bingxing"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bingxing] not found");
            }


            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, 90 * pi / 180, d1 / 2);
            var v2 = fun.Polar(v1, pi, l - d1 / 2);
            var v3 = fun.Polar(v0, pi, l);
            var v4 = fun.mirrorpoint(v2, v0, v3);
            var v5 = fun.mirrorpoint(v1, v0, v3);

            var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v4, v5, v1);
            polyline1.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);

            Milling_cutter.Morse_tapershank(dxf, v0, d1, L, l, msyz, bingxing);


            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度



            fun.dimrot1(dxf, v2, v4, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + d1, "", "");
            fun.dimrot1(dxf, v3, v5, 180, offset * 1.25, 0, height, arrowsize, exline, "APMX=" + l, "", "");
            fun.dimrot1(dxf, new Vector2(v0.X + L - l, v0.Y), v3, 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");


            var a1 = fun.Polar(v0, pi, l);
            var a2 = fun.Polar(a1, 0, L);
            var a3 = fun.Polar(a1, pi, d1 / 2);
            var a4 = fun.Polar(a2, 0, d1 / 2);
            Line line00 = new Line(a3, a4);
            line00.Layer = centre;
            line00.Lineweight = Lineweight.W25;
            line00.Linetype = Linetype.DashDot;
            dxf.AddEntity(line00);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard20773_4to5(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /*var a = 3;
            var d1 = 6;
            var d2 = 10;
            var l = 63;
            var L = 115;
            var bbxz = 0;*/

            var a = 3.0;//锥角
            try
            {
                a = Convert.ToDouble(data["ta"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[a] not found");
            }
            var d1 = 6.0;//切削直径
            try
            {
                d1 = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var d2 = 10.0;//连接直径
            try
            {
                d2 = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d2] not found");
            }
            var l = 63.0;//最大切削深度
            try
            {
                l = Convert.ToDouble(data["apmx"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l] not found");
            }
            var L = 115.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var bbxz = 0.0;//柄部型式
            try
            {
                bbxz = Convert.ToDouble(data["bbxz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bbxz] not found");
            }

            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, pi, l);
            var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
            var v3 = fun.Polar(v0, 90 * pi / 180, d1 / 2 + l * Math.Tan(a * pi / 180));
            var v4 = fun.mirrorpoint(v2, v0, v1);
            var v5 = fun.mirrorpoint(v3, v0, v1);

            var polyline1 = Pus.AddPointsToLwPolyLine(v3, v2, v4, v5, v3);
            //polyline1.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);



            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度



            fun.dimrot1(dxf, v2, v4, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + d1, "", "");
            fun.dimrot1(dxf, v4, v5, 180, offset * 1.25, 0, height, arrowsize, exline, "APMX=" + l, "", "");
            fun.dimrot1(dxf, new Vector2(v0.X + L - l, v0.Y), v4, 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");
            fun.jdbz2(dxf, new Line(v3, fun.Polar(v3, pi, 0.1)), new Line(v3, v2), offset * 2.5, height, arrowsize, exline, "a/2=" + a / 2, "", "");



            var a1 = fun.Polar(v0, pi, l);
            var a2 = fun.Polar(a1, 0, L);
            var a3 = fun.Polar(a1, pi, d1 / 2);
            var a4 = fun.Polar(a2, 0, d1 / 2);
            Line line00 = new Line(a3, a4);
            line00.Layer = centre;
            line00.Lineweight = Lineweight.W25;
            line00.Linetype = Linetype.DashDot;
            dxf.AddEntity(line00);

            Milling_cutter.Milling_shankDictionary(dxf, v0, d2, bbxz, L, l, d1 / 2 + l * Math.Tan(a * pi / 180) * 2,data);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard20773_6to7(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /* var a = 3;
             var d1 = 6;
             var d2 = 10;
             var l = 63;
             var L = 115;
             var bbxz = 0;*/
            var a = 3.0;//锥角
            try
            {
                a = Convert.ToDouble(data["ta"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[a] not found");
            }
            var d1 = 6.0;//切削直径
            try
            {
                d1 = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var d2 = 10.0;//连接直径
            try
            {
                d2 = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d2] not found");
            }
            var l = 63.0;//最大切削深度
            try
            {
                l = Convert.ToDouble(data["apmx"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l] not found");
            }
            var L = 115.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var bbxz = 0.0;//柄部型式
            try
            {
                bbxz = Convert.ToDouble(data["bbxz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bbxz] not found");
            }

            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, pi, l - d1 / 2);
            var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
            var v3 = fun.Polar(v0, 90 * pi / 180, d1 / 2 + (l - d1 / 2) * Math.Tan(a * pi / 180));
            var v4 = fun.mirrorpoint(v2, v0, v1);
            var v5 = fun.mirrorpoint(v3, v0, v1);

            var polyline1 = Pus.AddPointsToLwPolyLine(v3, v2, v4, v5, v3);
            polyline1.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);



            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度



            fun.dimrot1(dxf, v2, v4, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + d1, "", "");
            fun.dimrot1(dxf, fun.Polar(v0, pi, l), v5, 180, offset * 1.25, 0, height, arrowsize, exline, "APMX=" + l, "", "");
            fun.dimrot1(dxf, new Vector2(v0.X + L - l, v0.Y), fun.Polar(v0, pi, l), 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");
            fun.jdbz2(dxf, new Line(v3, fun.Polar(v3, pi, 0.1)), new Line(v3, v2), offset * 2.5, height, arrowsize, exline, "a/2=" + a / 2, "", "");


            var a1 = fun.Polar(v0, pi, l);
            var a2 = fun.Polar(a1, 0, L);
            var a3 = fun.Polar(a1, pi, d1 / 2);
            var a4 = fun.Polar(a2, 0, d1 / 2);
            Line line00 = new Line(a3, a4);
            line00.Layer = centre;
            line00.Lineweight = Lineweight.W25;
            line00.Linetype = Linetype.DashDot;
            dxf.AddEntity(line00);

            Milling_cutter.Milling_shankDictionary(dxf, v0, d2, bbxz, L, l, d1 / 2 + l * Math.Tan(a * pi / 180) * 2, data);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard20773_8(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /*var a = 3;
            var d1 = 20;
            var l = 100;
            var L = 202;
            var msyz = 3;
            var bingxing = 1;*/

            var a = 3.0;//锥角
            try
            {
                a = Convert.ToDouble(data["ta"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[a] not found");
            }
            var d1 = 20.0;//切削直径
            try
            {
                d1 = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var l = 100.0;//最大切削深度
            try
            {
                l = Convert.ToDouble(data["apmx"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l] not found");
            }
            var L = 202.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var msyz = 3.0;//莫氏锥柄号
            try
            {
                msyz = Convert.ToDouble(data["msyz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[msyz] not found");
            }
            var bingxing = 1.0;//莫氏锥柄号
            try
            {
                bingxing = Convert.ToDouble(data["bingxing"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bingxing] not found");
            }

            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, pi, l);
            var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
            var v3 = fun.Polar(v0, 90 * pi / 180, d1 / 2 + l * Math.Tan(a * pi / 180));
            var v4 = fun.mirrorpoint(v2, v0, v1);
            var v5 = fun.mirrorpoint(v3, v0, v1);

            var polyline1 = Pus.AddPointsToLwPolyLine(v3, v2, v4, v5, v3);
            //polyline1.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);



            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度



            fun.dimrot1(dxf, v2, v4, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + d1, "", "");
            fun.dimrot1(dxf, v4, v5, 180, offset * 1.25, 0, height, arrowsize, exline, "APMX=" + l, "", "");
            fun.dimrot1(dxf, new Vector2(v0.X + L - l, v0.Y), v4, 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");
            fun.jdbz2(dxf, new Line(v3, fun.Polar(v3, pi, 0.1)), new Line(v3, v2), offset * 2.5, height, arrowsize, exline, "a/2=" + a / 2, "", "");



            var a1 = fun.Polar(v0, pi, l);
            var a2 = fun.Polar(a1, 0, L);
            var a3 = fun.Polar(a1, pi, d1 / 2);
            var a4 = fun.Polar(a2, 0, d1 / 2);
            Line line00 = new Line(a3, a4);
            line00.Layer = centre;
            line00.Lineweight = Lineweight.W25;
            line00.Linetype = Linetype.DashDot;
            dxf.AddEntity(line00);

            Milling_cutter.Morse_tapershank(dxf, v0, d1, L, l, msyz, bingxing);

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard20773_9(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /*var a = 3;
            var d1 = 20;
            var l = 100;
            var L = 248;
            var msyz = 4;
            var bingxing = 2;*/
            var a = 3.0;//锥角
            try
            {
                a = Convert.ToDouble(data["ta"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[a] not found");
            }
            var d1 = 20.0;//切削直径
            try
            {
                d1 = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var l = 100.0;//最大切削深度
            try
            {
                l = Convert.ToDouble(data["apmx"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l] not found");
            }
            var L = 248.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var msyz = 4.0;//莫氏锥柄号
            try
            {
                msyz = Convert.ToDouble(data["msyz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[msyz] not found");
            }
            var bingxing = 2.0;//莫氏锥柄号
            try
            {
                bingxing = Convert.ToDouble(data["bingxing"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bingxing] not found");
            }

            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, pi, l - d1 / 2);
            var v2 = fun.Polar(v1, 90 * pi / 180, d1 / 2);
            var v3 = fun.Polar(v0, 90 * pi / 180, d1 / 2 + (l - d1 / 2) * Math.Tan(a * pi / 180));
            var v4 = fun.mirrorpoint(v2, v0, v1);
            var v5 = fun.mirrorpoint(v3, v0, v1);

            var polyline1 = Pus.AddPointsToLwPolyLine(v3, v2, v4, v5, v3);
            polyline1.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);



            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度



            fun.dimrot1(dxf, v2, v4, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + d1, "", "");
            fun.dimrot1(dxf, fun.Polar(v0, pi, l), v5, 180, offset * 1.25, 0, height, arrowsize, exline, "APMX=" + l, "", "");
            fun.dimrot1(dxf, new Vector2(v0.X + L - l, v0.Y), fun.Polar(v0, pi, l), 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");
            fun.jdbz2(dxf, new Line(v3, fun.Polar(v3, pi, 0.1)), new Line(v3, v2), offset * 2.5, height, arrowsize, exline, "a/2=" + a / 2, "", "");


            var a1 = fun.Polar(v0, pi, l);
            var a2 = fun.Polar(a1, 0, L);
            var a3 = fun.Polar(a1, pi, d1 / 2);
            var a4 = fun.Polar(a2, 0, d1 / 2);
            Line line00 = new Line(a3, a4);
            line00.Layer = centre;
            line00.Lineweight = Lineweight.W25;
            line00.Linetype = Linetype.DashDot;
            dxf.AddEntity(line00);

            Milling_cutter.Morse_tapershank(dxf, v0, d1, L, l, msyz, bingxing);



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard6338(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /*  var d1 = 12;
              var d2 = 16;
              var l1 = 4;
              var l2 = 60;
              var a = 45;
              var bbxz = 0;
              double zf = 1;*/

            var d1 = 12.0;//机床测连接直径
            try
            {
                d1 = Convert.ToDouble(data["dconms"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var d2 = 16.0;//切削直径
            try
            {
                d2 = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d2] not found");
            }
            var l1 = 4.0;//最大切削深度
            try
            {
                l1 = Convert.ToDouble(data["apmx"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l1] not found");
            }
            var l2 = 60.0;//总长度
            try
            {
                l2 = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l2] not found");
            }
            var a = 45.0;//刀具主偏角
            try
            {
                a = Convert.ToDouble(data["kapr"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[a] not found");
            }
            var bbxz = 0.0;//柄部型式
            try
            {
                bbxz = Convert.ToDouble(data["bbxz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bbxz] not found");
            }
            var zf = 1.0;//正反燕尾槽（0是正 1是反）
            try
            {
                zf = Convert.ToDouble(data["zf"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[zf] not found");
            }


            if (zf == 0)
            {
                //坐标
                var v0 = new Vector2(0, 0);
                var v1 = fun.Polar(v0, pi, l1);
                var v2 = fun.Polar(v1, 90 * pi / 180, d2 / 2);
                var v3 = fun.Inters(v2, fun.Polar(v2, -a * pi / 180, 1), v0, fun.Polar(v0, 90 * pi / 180, 1));
                var v4 = fun.mirrorpoint(v3, v0, v1);
                var v5 = fun.mirrorpoint(v2, v0, v1);


                var polyline1 = Pus.AddPointsToLwPolyLine(v2, v3, v4, v5, v2);
                fun.PolyFill(dxf, polyline1, 0.2, contour);

                var height = 2.5;//字体高度
                var offset = 10;//偏移量
                var arrowsize = 1;//箭头大小
                var exline = 1;//延伸线长度



                fun.dimrot1(dxf, v2, v5, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + d2, "", "");
                fun.dimrot1(dxf, v4, v5, 180, offset * 2.25, 0, height, arrowsize, exline, "APMX=" + l1, "", "");
                fun.dimrot1(dxf, new Vector2(v0.X + l2 - l1, v0.Y), fun.Polar(v0, pi, l1), 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + l2, "", "");
                fun.jdbz2(dxf, new Line(v5, v2), new Line(v3, v2), offset * 1.5, height, arrowsize, exline, "a=" + a + "°", "", "");


                var a1 = fun.Polar(v0, pi, l1);
                var a2 = fun.Polar(a1, 0, l2);
                var a3 = fun.Polar(a1, pi, 8);
                var a4 = fun.Polar(a2, 0, 8);
                Line line00 = new Line(a3, a4);
                line00.Layer = center;
                line00.Lineweight = Lineweight.W25;
                line00.Linetype = Linetype.DashDot;
                dxf.AddEntity(line00);

                Milling_cutter.Milling_shankDictionary(dxf, v0, d1, bbxz, l2, l1, fun.CalDistance(v3, v4),data);
            }
            else
            {
                //坐标
                var v0 = new Vector2(0, 0);
                var v1 = fun.Polar(v0, pi, l1);
                var v3 = fun.Polar(v0, 90 * pi / 180, d2 / 2);
                var v2 = fun.Inters(v3, fun.Polar(v3, (180 + a) * pi / 180, 1), v1, fun.Polar(v1, 90 * pi / 180, 1));
                var v4 = fun.mirrorpoint(v3, v0, v1);
                var v5 = fun.mirrorpoint(v2, v0, v1);


                var polyline1 = Pus.AddPointsToLwPolyLine(v2, v3, v4, v5, v2);
                fun.PolyFill(dxf, polyline1, 0.2, contour);

                var height = 2.5;//字体高度
                var offset = 10;//偏移量
                var arrowsize = 1;//箭头大小
                var exline = 1;//延伸线长度



                fun.dimrot1(dxf, v3, v4, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + d2, "", "");
                fun.dimrot1(dxf, v4, v5, 180, offset * 2.25, 0, height, arrowsize, exline, "APMX=" + l1, "", "");
                fun.dimrot1(dxf, new Vector2(v0.X + l2 - l1, v0.Y), fun.Polar(v0, pi, l1), 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + l2, "", "");
                fun.jdbz2(dxf, new Line(v2, v3), new Line(v4, v3), offset * 1.5, height, arrowsize, exline, "a=" + a + "°", "", "");


                var a1 = fun.Polar(v0, pi, l1);
                var a2 = fun.Polar(a1, 0, l2);
                var a3 = fun.Polar(a1, pi, 8);
                var a4 = fun.Polar(a2, 0, 8);
                Line line00 = new Line(a3, a4);
                line00.Layer = center;
                line00.Lineweight = Lineweight.W25;
                line00.Linetype = Linetype.DashDot;
                dxf.AddEntity(line00);

                Milling_cutter.Milling_shankDictionary(dxf, v0, d1, bbxz, l2, l1, d1,data);
            }

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard6124(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            var d1 = 10.0;//机侧连接直径
            try
            {
                d1 = Convert.ToDouble(data["dconms"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var d2 = 16.0;//切削直径
            try
            {
                d2 = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d2] not found");
            }
            var d3 = 7.0;//颈部直径
            try
            {
                d3 = Convert.ToDouble(data["dn"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d3] not found");
            }
            var c = 8.0;//最大切削深度
            try
            {
                c = Convert.ToDouble(data["cw"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[c] not found");
            }
            var l = 10.0;//颈部长度
            try
            {
                l = Convert.ToDouble(data["ln"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[l] not found");
            }
            var L = 62.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var f = 0.6;
            try
            {
                f = Convert.ToDouble(data["f"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[f] not found");
            }
            var g = 1.0;
            try
            {
                g = Convert.ToDouble(data["g"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[g] not found");
            }
            var T = 8.0;
            try
            {
                T = Convert.ToDouble(data["t"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[T] not found");
            }
            String bbxz = "普通直柄";//柄部型式
            try
            {
                bbxz = Convert.ToString(data["bbxz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bbxz] not found");
            }

            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, 90 * pi / 180, 0.8 * d2 / 2);
            var v2 = fun.Polar(v1, pi, 0.2 * c);
            var v3 = fun.Polar(v2, 90 * pi / 180, 0.2 * d2 / 2);
            var v3p1 = fun.Polar(v3, -90 * pi / 180, f);
            var v3p2 = fun.Polar(v3, pi, f);
            var v4 = fun.Polar(v3, pi, 0.8 * c);
            var v4p1 = fun.Polar(v4, 0, g);
            var v4p2 = fun.Polar(v4, -90 * pi / 180, g);
            var v5p1 = fun.mirrorpoint(v4p2, v0, fun.Polar(v0, 0, 1));
            var v5p2 = fun.mirrorpoint(v4p1, v0, fun.Polar(v0, 0, 1));
            var v6p1 = fun.mirrorpoint(v3p2, v0, fun.Polar(v0, 0, 1));
            var v6p2 = fun.mirrorpoint(v3p1, v0, fun.Polar(v0, 0, 1));
            var v7 = fun.mirrorpoint(v2, v0, fun.Polar(v0, 0, 1));
            var v8 = fun.mirrorpoint(v1, v0, fun.Polar(v0, 0, 1));


            var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v3p1, v3p2, v4p1, v4p2, v5p1, v5p2, v6p1, v6p2, v7, v8, v1);
            fun.PolyFill(dxf, polyline1, 0.2, contour);

            double bbxs = 0;
            if(bbxz=="普通直柄")
            {
                bbxs = 0;
            }
            if (bbxz == "削平直柄")
            {
                bbxs = 1;
            }
            if (bbxz == "2°削平直柄")
            {
                bbxs = 2;
            }
            if (bbxz == "螺纹柄")
            {
                bbxs = 3;
            }
            if (bbxz == "莫氏柄")
            {
                bbxs = 4;
            }

            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度

            if (bbxs != 4)
            {
                Milling_cutter.Milling_shankDictionary(dxf, v0, d1, bbxs, L, c, d3 / 0.8,data);
            }

            if (bbxs == 4)
            {
                double msyz = Convert.ToDouble(data["msyz"]);
                Milling_cutter.Morse_tapershank(dxf, v0, d1, L, c, msyz, 1);
            }


            fun.dimrot1(dxf, new Vector2(v5p1.X + L, v0.Y), v5p1, 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");
            fun.dimrot1(dxf, v4p1, v5p2, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + d2, "", "");
            fun.dimrot1(dxf, v5p1, v0, 180, offset * 1.5, 0, height, arrowsize, exline, "CW=" + c, "", "");


            /*
            fun.dimrot1(dxf, v4p2, v4p1, 0, offset , 0, height, arrowsize, exline, "f=" + f + "*45°", "", "");
            fun.dimrot1(dxf, v3p1, v3p2, 0, offset*2 , 0, height, arrowsize, exline, "f=" + f + "*45°", "", "");
            */
            var a1 = fun.Polar(v0, pi, c);
            var a2 = fun.Polar(a1, 0, L);
            var a3 = fun.Polar(a1, pi, d1 / 2);
            var a4 = fun.Polar(a2, 0, d1 / 2);
            Line line00 = new Line(a3, a4);
            line00.Layer = center;
            line00.Lineweight = Lineweight.W25;
            line00.Linetype = Linetype.DashDot;
            dxf.AddEntity(line00);

            //fun.seevector2(dxf, "V", 1, 1, v5p1);



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard1127(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            var d = 28.5;//切削直径
            try
            {
                d = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var b = 8.0;//最大切削深度
            try
            {
                b = Convert.ToDouble(data["apmx"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[b] not found");
            }
            var d1 = 12.0;//柄部直径
            try
            {
                d1 = Convert.ToDouble(data["dmm"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var L = 65.0;//总长度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var bbxz = 0.0;//柄部型式
            try
            {
                bbxz = Convert.ToDouble(data["bbxz"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[bbxz] not found");
            }

            if (b <= 2.5)
            {
                //坐标
                var v0 = new Vector2(0, 0);
                var v1 = fun.Polar(v0, 90 * pi / 180, d / 2);
                var v2 = fun.Polar(v1, pi, b);
                var v3 = fun.Polar(v2, -90 * pi / 180, 0.6 * d / 2);
                var v4 = fun.Polar(v3, pi, 9.5 * b / 15.5);
                var v5 = fun.Polar(v0, pi, 37.5 * b / 15.5);
                var v6 = new Vector2(v1.X, v3.Y);
                var v7 = fun.Polar(v6, pi, 4.5 * b / 15.5);
                var v8 = fun.Polar(v7, 90 * pi / 180, 8 * d / 40);
                var v10 = fun.Polar(v3, 0, 4.5 * b / 15.5);
                var v9 = new Vector2(v10.X, v8.Y);
                var v11 = fun.mirrorpoint(v4, v0, v5);
                var v12 = fun.mirrorpoint(v3, v0, v5);
                var v13 = fun.mirrorpoint(v2, v0, v5);
                var v14 = fun.mirrorpoint(v1, v0, v5);
                var v15 = fun.Polar(v13, 90 * pi / 180, 3 * d / 40);
                var v16 = new Vector2(v14.X, v15.Y);
                var v17 = fun.Polar(v15, 90 * pi / 180, 3 * d / 40);
                var v18 = new Vector2(v14.X, v17.Y);
                var v19 = new Vector2(v4.X + (v3.X - v4.X) / 2, v4.Y - (v4.Y - v5.Y) / 2);
                var v20 = new Vector2(v3.X, v0.Y);



                var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v3, v4, v5, v11, v12, v13, v14, v1);
                fun.PolyFill(dxf, polyline1, 0.2, contour);
                var polyline2 = Pus.AddPointsToLwPolyLine(v6, v7, v8, v9, v10, v3);
                fun.PolyFill(dxf, polyline2, 0.2, contour);
                var polyline3 = Pus.AddPointsToLwPolyLine(v4, v20);
                fun.PolyFill(dxf, polyline3, 0.2, contour);
                var line1 = new Line(v4, v11);
                fun.drawBline(dxf, line1, 0.2, contour);
                var line2 = new Line(v15, v16);
                fun.drawBline(dxf, line2, 0.2, contour);
                var line3 = new Line(v17, v18);
                fun.drawBline(dxf, line3, 0.2, contour);
                var line4 = new Line(v2, v9);
                fun.drawBline(dxf, line4, 0.2, contour);
                var line5 = new Line(v8, v1);
                fun.drawBline(dxf, line5, 0.2, contour);


                Milling_cutter.Milling_shankDictionary(dxf, v0, d1, bbxz, L, fun.CalDistance(v0, v5), d,data);

                var height = 2.5;//字体高度
                var offset = 10;//偏移量
                var arrowsize = 1;//箭头大小
                var exline = 1;//延伸线长度

                var hatchpoly1 = Pus.AddPointsToLwPolyLine(v0, v6, v7, v8, v9, v10, v3, v4, v20, v0);
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);


                fun.dimrot1(dxf, v2, v13, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + d, "", "");
                fun.dimrot1(dxf, v13, v14, 0, offset * 1, 0, height, arrowsize, exline, "APMX=" + b, "", "");
                fun.dimrot1(dxf, new Vector2(v5.X + L, v0.Y), v5, 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");


                var a1 = v5;
                var a2 = fun.Polar(a1, 0, L);
                var a3 = fun.Polar(a1, pi, d1 / 2);
                var a4 = fun.Polar(a2, 0, d1 / 2);
                Line line00 = new Line(a3, a4);
                line00.Layer = centre;
                line00.Lineweight = Lineweight.W25;
                line00.Linetype = Linetype.DashDot;
                dxf.AddEntity(line00);


                var v21 = fun.Polar(v5, pi, 40);
                var v22 = fun.Polar(v21, pi, 1.5 * d);
                var v23 = fun.Polar(v21, -90 * pi / 180, 1.5 * d);
                var v24 = fun.Polar(v21, 0, 1.5 * d);
                var v25 = fun.Polar(v21, 90 * pi / 180, 1.5 * d);


                Line line6 = new Line(v22, v24);
                line6.Layer = centre;
                line6.Lineweight = Lineweight.W25;
                line6.Linetype = Linetype.DashDot;
                dxf.AddEntity(line6);
                Line line7 = new Line(v23, v25);
                line7.Layer = centre;
                line7.Lineweight = Lineweight.W25;
                line7.Linetype = Linetype.DashDot;
                dxf.AddEntity(line7);
                var polyline4 = Pus.AddPointsToLwPolyLine(fun.Polar(v21, pi, 0.36 * d / 2), fun.Polar(v21, 0, 0.36 * d / 2), fun.Polar(v21, pi, 0.36 * d / 2));
                polyline4.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                polyline4.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                fun.PolyFill(dxf, polyline4, 0.2, contour);
                var polyline5 = Pus.AddPointsToLwPolyLine(fun.Polar(v21, pi, 0.57 * d / 2), fun.Polar(v21, 0, 0.57 * d / 2), fun.Polar(v21, pi, 0.57 * d / 2));
                polyline5.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                polyline5.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                fun.PolyFill(dxf, polyline5, 0.2, contour);
                var v26 = fun.Polar(v21, 93 * pi / 180, 17.25 / 42.5 * d);
                var v27 = fun.Polar(v21, 81 * pi / 180, 27.14 / 42.5 * d);
                var v28 = fun.Polar(v21, 33 * pi / 180, 17.25 / 42.5 * d);
                var v29 = fun.Polar(v21, 21 * pi / 180, 27.14 / 42.5 * d);
                var v30 = fun.Polar(v21, -27 * pi / 180, 17.25 / 42.5 * d);
                var v31 = fun.Polar(v21, -39 * pi / 180, 27.14 / 42.5 * d);
                var v32 = fun.Polar(v21, -87 * pi / 180, 17.25 / 42.5 * d);
                var v33 = fun.Polar(v21, -99 * pi / 180, 27.14 / 42.5 * d);
                var v34 = fun.Polar(v21, -147 * pi / 180, 17.25 / 42.5 * d);
                var v35 = fun.Polar(v21, -159 * pi / 180, 27.14 / 42.5 * d);
                var v36 = fun.Polar(v21, -207 * pi / 180, 17.25 / 42.5 * d);
                var v37 = fun.Polar(v21, -219 * pi / 180, 27.14 / 42.5 * d);
                var r = 8.5 / 46 * d / 2;
                var v380 = fun.Inters(v26, v37, v21, v25);
                var polyline6 = Pus.AddPointsToLwPolyLine(v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v26);
                var polyline7 = Pus.Fillet4LwPline(polyline6, 1, r);
                var polyline8 = Pus.Fillet4LwPline(polyline7, 3, r);
                var polyline9 = Pus.Fillet4LwPline(polyline8, 5, r);
                var polyline10 = Pus.Fillet4LwPline(polyline9, 7, r);
                var polyline11 = Pus.Fillet4LwPline(polyline10, 9, r);
                var polyline12 = Pus.Fillet4LwPline(polyline11, 11, r);
                var polyline13 = Pus.Fillet4LwPline(polyline12, 13, r);
                var polyline14 = Pus.Fillet4LwPline(polyline13, 15, r);
                var polyline15 = Pus.Fillet4LwPline(polyline14, 17, r);
                var polyline16 = Pus.Fillet4LwPline(polyline15, 19, r);
                var polyline17 = Pus.Fillet4LwPline(polyline16, 21, r);
                //var polyline18 = Pus.Fillet4LwPline(polyline17, 23, r);
                fun.PolyFill(dxf, polyline17, 0.2, contour);
            }
            else if (b > 2.5 && b <= 5)
            {
                //坐标
                var D = 4.04 * 58.22 / 144.88 * d / 3.27;
                var v0 = new Vector2(0, 0);
                var v1 = fun.Polar(v0, 90 * pi / 180, d / 2);
                var v2 = fun.Polar(v1, pi, b);
                var v3 = new Vector2(v2.X, v0.Y + D / 2);
                var v4 = fun.Polar(v3, pi, 29.46 / 41.04 * b);
                var v5 = fun.mirrorpoint(v4, v0, fun.Polar(v0, 0, 1));
                var v6 = fun.mirrorpoint(v3, v0, fun.Polar(v0, 0, 1));
                var v7 = fun.mirrorpoint(v2, v0, fun.Polar(v0, 0, 1));
                var v8 = fun.mirrorpoint(v1, v0, fun.Polar(v0, 0, 1));
                var v9 = new Vector2(v1.X, v3.Y);
                var v10 = fun.Polar(v9, pi, 6.78 / 41.04 * b);
                var v11 = fun.Polar(v10, 90 * pi / 180, 27.71 / 144.88 * d);
                var v12 = fun.mirrorpoint(v11, fun.Polar(v1, pi, b / 2), fun.Polar(fun.Polar(v1, pi, b / 2), -90 * pi / 180, 1));
                var v13 = fun.mirrorpoint(v10, fun.Polar(v1, pi, b / 2), fun.Polar(fun.Polar(v1, pi, b / 2), -90 * pi / 180, 1));
                var v14 = fun.Polar(v10, 90 * pi / 180, fun.CalDistance(v11, v10) / 2);
                var v15 = fun.Polar(v14, pi, 8.76 / 41.04 * b);
                var v16 = new Vector2(v15.X, v10.Y);
                var v17 = fun.mirrorpoint(v14, fun.Polar(v1, pi, b / 2), fun.Polar(fun.Polar(v1, pi, b / 2), -90 * pi / 180, 1));
                var v18 = fun.mirrorpoint(v15, fun.Polar(v1, pi, b / 2), fun.Polar(fun.Polar(v1, pi, b / 2), -90 * pi / 180, 1));
                var v19 = fun.mirrorpoint(v16, fun.Polar(v1, pi, b / 2), fun.Polar(fun.Polar(v1, pi, b / 2), -90 * pi / 180, 1));
                var v20 = new Vector2(v4.X + 13.79 / 41.04 * b, v0.Y);
                var v21 = fun.Polar(v20, 90 * pi / 180, 11.07 / 58.22 * D);
                var v22 = new Vector2(v2.X, v21.Y);
                var v23 = new Vector2(v22.X, v0.Y);
                var v24 = new Vector2(v19.X, v0.Y);
                var v25 = fun.Polar(v23, -90 * pi / 180, 12.48 / 58.22 * D);
                var v26 = new Vector2(v0.X, v25.Y);
                var v27 = fun.Polar(v7, 90 * pi / 180, 24.63 / 144.88 * d);
                var v28 = new Vector2(v0.X, v27.Y);
                var v29 = fun.Polar(v7, 90 * pi / 180, 14.96 / 144.88 * d);
                var v30 = new Vector2(v0.X, v29.Y);



                var polyline1 = Pus.AddPointsToLwPolyLine(v9, v1, v2, v3, v4, v5, v6, v7, v8, v0);
                var polyline2 = Pus.AddPointsToLwPolyLine(v3, v13, v12, v11, v10, v9);
                var polyline3 = Pus.AddPointsToLwPolyLine(v17, v18, v19, v13);
                var polyline4 = Pus.AddPointsToLwPolyLine(v10, v16, v15, v14);
                var polyline5 = Pus.AddPointsToLwPolyLine(v4, v21, v22, v24);
                fun.PolyFill(dxf, polyline1, 0.2, contour);
                fun.PolyFill(dxf, polyline2, 0.2, contour);
                fun.PolyFill(dxf, polyline3, 0.2, contour);
                fun.PolyFill(dxf, polyline4, 0.2, contour);
                fun.PolyFill(dxf, polyline5, 0.2, contour);
                var line1 = new Line(v1, v11);
                var line2 = new Line(v2, v12);
                var line3 = new Line(v21, v20);
                var line4 = new Line(v22, v23);
                var line5 = new Line(v25, v26);
                var line6 = new Line(v27, v28);
                var line7 = new Line(v29, v30);
                var line8 = new Line(v23, v6);
                fun.drawBline(dxf, line1, 0.2, contour);
                fun.drawBline(dxf, line2, 0.2, contour);
                fun.drawBline(dxf, line3, 0.2, contour);
                fun.drawBline(dxf, line4, 0.2, contour);
                fun.drawBline(dxf, line5, 0.2, contour);
                fun.drawBline(dxf, line6, 0.2, contour);
                fun.drawBline(dxf, line7, 0.2, contour);
                fun.drawBline(dxf, line8, 0.2, contour);


                var a1 = new Vector2(v4.X, v0.Y);
                var a2 = fun.Polar(a1, 0, L);
                var a3 = fun.Polar(a1, pi, d1 / 2);
                var a4 = fun.Polar(a2, 0, d1 / 2);
                Line line00 = new Line(a3, a4);
                line00.Layer = centre;
                line00.Lineweight = Lineweight.W25;
                line00.Linetype = Linetype.DashDot;
                dxf.AddEntity(line00);

                var v31 = fun.Polar(v9, 0, 24.5 / 41.04 * b);
                var v33 = fun.Polar(v0, 0, 8 / 41.04 * b);
                var v32 = fun.Polar(v31, fun.CalAngle(v31, v33), fun.CalDistance(v31, v33) / 2);

                var polyline6 = Pus.AddPointsToLwPolyLine(v31, v32, v33);
                polyline6.Vertexes[0].Bulge = Math.Tan(60 * Math.PI / 180 / 4);
                polyline6.Vertexes[1].Bulge = Math.Tan(-60 * Math.PI / 180 / 4);
                polyline6.Lineweight = Lineweight.W25;
                polyline6.Layer = additionalline;
                dxf.AddEntity(polyline6);

                Milling_cutter.Milling_shankDictionary(dxf, v0, d1, bbxz, L, v9.X - v4.X, D * 4.04 / 3.27, data);

                var hatchpoly1 = Pus.AddPointsToLwPolyLine(v31, v32, v33, v24, v22, v21, v4, v19, v18, v17, v12, v11, v14, v15, v16, v31);
                hatchpoly1.Vertexes[0].Bulge = Math.Tan(60 * Math.PI / 180 / 4);
                hatchpoly1.Vertexes[1].Bulge = Math.Tan(-60 * Math.PI / 180 / 4);
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);


                var height = 2.5;//字体高度
                var offset = 10;//偏移量
                var arrowsize = 1;//箭头大小
                var exline = 1;//延伸线长度


                fun.dimrot1(dxf, v2, v7, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + d, "", "");
                fun.dimrot1(dxf, v1, v2, 0, offset * 1, 0, height, arrowsize, exline, "APMX=" + b, "", "");
                fun.dimrot1(dxf, new Vector2(v4.X, v0.Y), fun.Polar(new Vector2(v4.X, v0.Y), 0, L), 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");


                var v34 = fun.Polar(v20, pi, 50);
                var v35 = fun.Polar(v34, pi, 0.8 * d);
                var v36 = fun.Polar(v34, -90 * pi / 180, 0.8 * d);
                var v37 = fun.Polar(v34, 0, 0.8 * d);
                var v38 = fun.Polar(v34, 90 * pi / 180, 0.8 * d);


                Line line06 = new Line(v35, v37);
                line06.Layer = centre;
                line06.Lineweight = Lineweight.W25;
                line06.Linetype = Linetype.DashDot;
                dxf.AddEntity(line06);
                Line line07 = new Line(v36, v38);
                line07.Layer = centre;
                line07.Lineweight = Lineweight.W25;
                line07.Linetype = Linetype.DashDot;
                dxf.AddEntity(line07);

                var polyline7 = Pus.AddPointsToLwPolyLine(fun.Polar(v34, pi, fun.CalDistance(v4, v5) * 3 / 8), fun.Polar(v34, 0, fun.CalDistance(v4, v5) * 3 / 8), fun.Polar(v34, pi, fun.CalDistance(v4, v5) * 3 / 8));
                polyline7.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                polyline7.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                fun.PolyFill(dxf, polyline7, 0.2, contour);
                var polyline8 = Pus.AddPointsToLwPolyLine(fun.Polar(v34, pi, fun.CalDistance(v4, v5) / 2), fun.Polar(v34, 0, fun.CalDistance(v4, v5) / 2), fun.Polar(v34, pi, fun.CalDistance(v4, v5) / 2));
                polyline8.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                polyline8.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                fun.PolyFill(dxf, polyline8, 0.2, contour);

                var r = 0.51 / 13.5 * d;

                var v39 = fun.Polar(v34, 90 * pi / 180, 6.24 / 13.5 * d);
                var v40 = fun.Polar(v34, 82 * pi / 180, 6.6 / 13.5 * d);
                var v41 = fun.Polar(v34, 56 * pi / 180, 4.82 / 13.5 * d);
                var v42 = fun.Polar(v34, 45 * pi / 180, 5.52 / 13.5 * d);

                var v43 = fun.rotatePoint_Changed(v34, v39, -45);
                var v44 = fun.rotatePoint_Changed(v34, v40, -45);
                var v45 = fun.rotatePoint_Changed(v34, v41, -45);
                var v46 = fun.rotatePoint_Changed(v34, v42, -45);

                var v47 = fun.rotatePoint_Changed(v34, v43, -45);
                var v48 = fun.rotatePoint_Changed(v34, v44, -45);
                var v49 = fun.rotatePoint_Changed(v34, v45, -45);
                var v50 = fun.rotatePoint_Changed(v34, v46, -45);

                var v51 = fun.rotatePoint_Changed(v34, v47, -45);
                var v52 = fun.rotatePoint_Changed(v34, v48, -45);
                var v53 = fun.rotatePoint_Changed(v34, v49, -45);
                var v54 = fun.rotatePoint_Changed(v34, v50, -45);

                var v55 = fun.rotatePoint_Changed(v34, v51, -45);
                var v56 = fun.rotatePoint_Changed(v34, v52, -45);
                var v57 = fun.rotatePoint_Changed(v34, v53, -45);
                var v58 = fun.rotatePoint_Changed(v34, v54, -45);

                var v59 = fun.rotatePoint_Changed(v34, v55, -45);
                var v60 = fun.rotatePoint_Changed(v34, v56, -45);
                var v61 = fun.rotatePoint_Changed(v34, v57, -45);
                var v62 = fun.rotatePoint_Changed(v34, v58, -45);

                var v63 = fun.rotatePoint_Changed(v34, v59, -45);
                var v64 = fun.rotatePoint_Changed(v34, v60, -45);
                var v65 = fun.rotatePoint_Changed(v34, v61, -45);
                var v66 = fun.rotatePoint_Changed(v34, v62, -45);

                var v67 = fun.rotatePoint_Changed(v34, v63, -45);
                var v68 = fun.rotatePoint_Changed(v34, v64, -45);
                var v69 = fun.rotatePoint_Changed(v34, v65, -45);
                var v70 = fun.rotatePoint_Changed(v34, v66, -45);



                var polyline9 = Pus.AddPointsToLwPolyLine(v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63, v64, v65, v66, v67, v68, v69, v70, v39);

                polyline9.Vertexes[0].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[2].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[4].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[6].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[8].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[10].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[12].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[14].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[16].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[18].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[20].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[22].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[24].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[26].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[28].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[30].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                fun.PolyFill(dxf, polyline9, 0.2, contour);


            }
            else
            {
                //坐标
                var D = 0.9 * d1;
                var v0 = new Vector2(0, 0);
                var v1 = fun.Polar(v0, 90 * pi / 180, d / 2);
                var v2 = fun.Polar(v1, pi, b);
                var v3 = new Vector2(v2.X, v0.Y + D / 2);
                var v4 = fun.Polar(v3, pi, 29.46 / 41.04 * b);
                var v5 = fun.mirrorpoint(v4, v0, fun.Polar(v0, 0, 1));
                var v6 = fun.mirrorpoint(v3, v0, fun.Polar(v0, 0, 1));
                var v7 = fun.mirrorpoint(v2, v0, fun.Polar(v0, 0, 1));
                var v8 = fun.mirrorpoint(v1, v0, fun.Polar(v0, 0, 1));
                var v9 = new Vector2(v1.X, v3.Y);
                var v10 = fun.Polar(v9, pi, 6.78 / 41.04 * b);
                var v11 = fun.Polar(v10, 90 * pi / 180, 27.71 / 144.88 * d);
                var v12 = fun.mirrorpoint(v11, fun.Polar(v1, pi, b / 2), fun.Polar(fun.Polar(v1, pi, b / 2), -90 * pi / 180, 1));
                var v13 = fun.mirrorpoint(v10, fun.Polar(v1, pi, b / 2), fun.Polar(fun.Polar(v1, pi, b / 2), -90 * pi / 180, 1));
                var v14 = fun.Polar(v10, 90 * pi / 180, fun.CalDistance(v11, v10) / 2);
                var v15 = fun.Polar(v14, pi, 8.76 / 41.04 * b);
                var v16 = new Vector2(v15.X, v10.Y);
                var v17 = fun.mirrorpoint(v14, fun.Polar(v1, pi, b / 2), fun.Polar(fun.Polar(v1, pi, b / 2), -90 * pi / 180, 1));
                var v18 = fun.mirrorpoint(v15, fun.Polar(v1, pi, b / 2), fun.Polar(fun.Polar(v1, pi, b / 2), -90 * pi / 180, 1));
                var v19 = fun.mirrorpoint(v16, fun.Polar(v1, pi, b / 2), fun.Polar(fun.Polar(v1, pi, b / 2), -90 * pi / 180, 1));
                var v20 = new Vector2(v4.X + 13.79 / 41.04 * b, v0.Y);
                var v21 = fun.Polar(v20, 90 * pi / 180, 11.07 / 58.22 * D);
                var v22 = new Vector2(v2.X, v21.Y);
                var v23 = new Vector2(v22.X, v0.Y);
                var v24 = new Vector2(v19.X, v0.Y);
                var v25 = fun.Polar(v23, -90 * pi / 180, 12.48 / 58.22 * D);
                var v26 = new Vector2(v0.X, v25.Y);
                var v27 = fun.Polar(v7, 90 * pi / 180, 24.63 / 144.88 * d);
                var v28 = new Vector2(v0.X, v27.Y);
                var v29 = fun.Polar(v7, 90 * pi / 180, 14.96 / 144.88 * d);
                var v30 = new Vector2(v0.X, v29.Y);



                var polyline1 = Pus.AddPointsToLwPolyLine(v9, v1, v2, v3, v4, v5, v6, v7, v8, v0);
                var polyline2 = Pus.AddPointsToLwPolyLine(v3, v13, v12, v11, v10, v9);
                var polyline3 = Pus.AddPointsToLwPolyLine(v17, v18, v19, v13);
                var polyline4 = Pus.AddPointsToLwPolyLine(v10, v16, v15, v14);
                var polyline5 = Pus.AddPointsToLwPolyLine(v4, v21, v22, v24);
                fun.PolyFill(dxf, polyline1, 0.2, contour);
                fun.PolyFill(dxf, polyline2, 0.2, contour);
                fun.PolyFill(dxf, polyline3, 0.2, contour);
                fun.PolyFill(dxf, polyline4, 0.2, contour);
                fun.PolyFill(dxf, polyline5, 0.2, contour);
                var line1 = new Line(v1, v11);
                var line2 = new Line(v2, v12);
                var line3 = new Line(v21, v20);
                var line4 = new Line(v22, v23);
                var line5 = new Line(v25, v26);
                var line6 = new Line(v27, v28);
                var line7 = new Line(v29, v30);
                var line8 = new Line(v23, v6);
                fun.drawBline(dxf, line1, 0.2, contour);
                fun.drawBline(dxf, line2, 0.2, contour);
                fun.drawBline(dxf, line3, 0.2, contour);
                fun.drawBline(dxf, line4, 0.2, contour);
                // fun.drawBline(dxf, line5, 0.2, contour);
                // fun.drawBline(dxf, line6, 0.2, contour);
                //fun.drawBline(dxf, line7, 0.2, contour);
                fun.drawBline(dxf, line8, 0.2, contour);


                var a1 = new Vector2(v4.X, v0.Y);
                var a2 = fun.Polar(a1, 0, L);
                var a3 = fun.Polar(a1, pi, d1 / 2);
                var a4 = fun.Polar(a2, 0, d1 / 2);
                Line line00 = new Line(a3, a4);
                line00.Layer = centre;
                line00.Lineweight = Lineweight.W25;
                line00.Linetype = Linetype.DashDot;
                dxf.AddEntity(line00);

                var v31 = fun.Polar(v9, 0, 24.5 / 41.04 * b);
                var v33 = fun.Polar(v0, 0, 8 / 41.04 * b);
                var v32 = fun.Polar(v31, fun.CalAngle(v31, v33), fun.CalDistance(v31, v33) / 2);

                var polyline6 = Pus.AddPointsToLwPolyLine(v31, v32, v33);
                polyline6.Vertexes[0].Bulge = Math.Tan(60 * Math.PI / 180 / 4);
                polyline6.Vertexes[1].Bulge = Math.Tan(-60 * Math.PI / 180 / 4);
                polyline6.Lineweight = Lineweight.W25;
                polyline6.Layer = additionalline;
                dxf.AddEntity(polyline6);

                Milling_cutter.Milling_shankDictionary(dxf, v0, d1, bbxz, L, v9.X - v4.X, D * 4.04 / 3.27,data);

                var hatchpoly1 = Pus.AddPointsToLwPolyLine(v31, v32, v33, v24, v22, v21, v4, v19, v18, v17, v12, v11, v14, v15, v16, v31);
                hatchpoly1.Vertexes[0].Bulge = Math.Tan(60 * Math.PI / 180 / 4);
                hatchpoly1.Vertexes[1].Bulge = Math.Tan(-60 * Math.PI / 180 / 4);
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 1, hline1, harc1, hatching);


                var height = 2.5;//字体高度
                var offset = 10;//偏移量
                var arrowsize = 1;//箭头大小
                var exline = 1;//延伸线长度


                fun.dimrot1(dxf, v2, v7, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + d, "", "");
                fun.dimrot1(dxf, v1, v2, 0, offset * 1, 0, height, arrowsize, exline, "APMX=" + b, "", "");
                fun.dimrot1(dxf, new Vector2(v4.X, v0.Y), fun.Polar(new Vector2(v4.X, v0.Y), 0, L), 180, offset * 4, 0, height, arrowsize, exline, "OAL=" + L, "", "");


                var v34 = fun.Polar(v20, pi, 50);
                var v35 = fun.Polar(v34, pi, 0.8 * d);
                var v36 = fun.Polar(v34, -90 * pi / 180, 0.8 * d);
                var v37 = fun.Polar(v34, 0, 0.8 * d);
                var v38 = fun.Polar(v34, 90 * pi / 180, 0.8 * d);


                Line line06 = new Line(v35, v37);
                line06.Layer = centre;
                line06.Lineweight = Lineweight.W25;
                line06.Linetype = Linetype.DashDot;
                dxf.AddEntity(line06);
                Line line07 = new Line(v36, v38);
                line07.Layer = centre;
                line07.Lineweight = Lineweight.W25;
                line07.Linetype = Linetype.DashDot;
                dxf.AddEntity(line07);

                var polyline7 = Pus.AddPointsToLwPolyLine(fun.Polar(v34, pi, fun.CalDistance(v4, v5) * 3 / 8), fun.Polar(v34, 0, fun.CalDistance(v4, v5) * 3 / 8), fun.Polar(v34, pi, fun.CalDistance(v4, v5) * 3 / 8));
                polyline7.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                polyline7.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                fun.PolyFill(dxf, polyline7, 0.2, contour);
                var polyline8 = Pus.AddPointsToLwPolyLine(fun.Polar(v34, pi, fun.CalDistance(v4, v5) / 2), fun.Polar(v34, 0, fun.CalDistance(v4, v5) / 2), fun.Polar(v34, pi, fun.CalDistance(v4, v5) / 2));
                polyline8.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                polyline8.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                fun.PolyFill(dxf, polyline8, 0.2, contour);

                var r = 0.51 / 13.5 * d;

                var v39 = fun.Polar(v34, 90 * pi / 180, 6.24 / 13.5 * d);
                var v40 = fun.Polar(v34, 82 * pi / 180, 6.6 / 13.5 * d);
                var v41 = fun.Polar(v34, 56 * pi / 180, 4.82 / 13.5 * d);
                var v42 = fun.Polar(v34, 45 * pi / 180, 5.52 / 13.5 * d);

                var v43 = fun.rotatePoint_Changed(v34, v39, -45);
                var v44 = fun.rotatePoint_Changed(v34, v40, -45);
                var v45 = fun.rotatePoint_Changed(v34, v41, -45);
                var v46 = fun.rotatePoint_Changed(v34, v42, -45);

                var v47 = fun.rotatePoint_Changed(v34, v43, -45);
                var v48 = fun.rotatePoint_Changed(v34, v44, -45);
                var v49 = fun.rotatePoint_Changed(v34, v45, -45);
                var v50 = fun.rotatePoint_Changed(v34, v46, -45);

                var v51 = fun.rotatePoint_Changed(v34, v47, -45);
                var v52 = fun.rotatePoint_Changed(v34, v48, -45);
                var v53 = fun.rotatePoint_Changed(v34, v49, -45);
                var v54 = fun.rotatePoint_Changed(v34, v50, -45);

                var v55 = fun.rotatePoint_Changed(v34, v51, -45);
                var v56 = fun.rotatePoint_Changed(v34, v52, -45);
                var v57 = fun.rotatePoint_Changed(v34, v53, -45);
                var v58 = fun.rotatePoint_Changed(v34, v54, -45);

                var v59 = fun.rotatePoint_Changed(v34, v55, -45);
                var v60 = fun.rotatePoint_Changed(v34, v56, -45);
                var v61 = fun.rotatePoint_Changed(v34, v57, -45);
                var v62 = fun.rotatePoint_Changed(v34, v58, -45);

                var v63 = fun.rotatePoint_Changed(v34, v59, -45);
                var v64 = fun.rotatePoint_Changed(v34, v60, -45);
                var v65 = fun.rotatePoint_Changed(v34, v61, -45);
                var v66 = fun.rotatePoint_Changed(v34, v62, -45);

                var v67 = fun.rotatePoint_Changed(v34, v63, -45);
                var v68 = fun.rotatePoint_Changed(v34, v64, -45);
                var v69 = fun.rotatePoint_Changed(v34, v65, -45);
                var v70 = fun.rotatePoint_Changed(v34, v66, -45);



                var polyline9 = Pus.AddPointsToLwPolyLine(v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63, v64, v65, v66, v67, v68, v69, v70, v39);

                polyline9.Vertexes[0].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[2].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[4].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[6].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[8].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[10].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[12].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[14].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[16].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[18].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[20].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[22].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[24].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[26].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                polyline9.Vertexes[28].Bulge = Math.Tan(-146 * Math.PI / 180 / 4);
                polyline9.Vertexes[30].Bulge = Math.Tan(98 * Math.PI / 180 / 4);
                fun.PolyFill(dxf, polyline9, 0.2, contour);
            }


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard1115_1(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            var D = 50.0;//切削直径
            try
            {
                D = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[D] not found");
            }
            var d = 22.0;//连接直径
            try
            {
                d = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var L = 50.0;//最小切削宽度
            try
            {
                L = Convert.ToDouble(data["cwn"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, 90 * pi / 180, D / 2);
            var v2 = fun.Polar(v1, 0, L);
            var v3 = fun.Polar(v2, -90 * pi / 180, D);
            var v4 = new Vector2(v1.X, v3.Y);
            var v5 = fun.Polar(v3, 90 * pi / 180, 0.1484 * D);
            var v6 = new Vector2(v4.X, v5.Y);
            var v7 = fun.Polar(v3, 90 * pi / 180, 0.2725 * D);
            var v8 = new Vector2(v4.X, v7.Y);
            var v0p = fun.Polar(v0, 0, L);
            var v9 = fun.Polar(v0p, pi, 0.046 * L);
            var v10 = fun.mirrorpoint(v9, fun.Polar(v0, 0, L / 2), fun.Polar(fun.Polar(v0, 0, L / 2), -90 * pi / 180, 1));
            var v11 = fun.Polar(v9, -90 * pi / 180, 0.1722 * D);
            var v12 = fun.mirrorpoint(v11, fun.Polar(v0, 0, L / 2), fun.Polar(fun.Polar(v0, 0, L / 2), -90 * pi / 180, 1));
            var v13 = fun.Polar(v9, pi, 0.2297 * L);
            var v14 = new Vector2(v13.X, v11.Y);
            var v15 = fun.Polar(v14, -90 * pi / 180, (v14.Y - v7.Y) / 2);
            var v16 = fun.mirrorpoint(v15, fun.Polar(v0, 0, L / 2), fun.Polar(fun.Polar(v0, 0, L / 2), -90 * pi / 180, 1));
            var v17 = fun.mirrorpoint(v14, fun.Polar(v0, 0, L / 2), fun.Polar(fun.Polar(v0, 0, L / 2), -90 * pi / 180, 1));
            var v18 = fun.mirrorpoint(v13, fun.Polar(v0, 0, L / 2), fun.Polar(fun.Polar(v0, 0, L / 2), -90 * pi / 180, 1));
            var v19 = fun.Polar(v0, pi, 5);
            var v20 = fun.Polar(v0p, 0, 5);



            var polyline1 = Pus.AddPointsToLwPolyLine(v1, v2, v3, v4, v1);
            var polyline2 = Pus.AddPointsToLwPolyLine(v10, v12, v8);
            var polyline3 = Pus.AddPointsToLwPolyLine(v9, v11, v7);
            var polyline4 = Pus.AddPointsToLwPolyLine(v18, v16, v15, v13);
            var polyline5 = Pus.Fillet4LwPline(polyline4, 1, v17.Y - v16.Y);
            var polyline6 = Pus.Fillet4LwPline(polyline5, 3, v17.Y - v16.Y);
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            fun.PolyFill(dxf, polyline2, 0.2, contour);
            fun.PolyFill(dxf, polyline3, 0.2, contour);
            fun.PolyFill(dxf, polyline6, 0.2, contour);
            Line line1 = new Line(v19, v20);
            line1.Layer = centre;
            line1.Lineweight = Lineweight.W25;
            line1.Linetype = Linetype.DashDot;
            dxf.AddEntity(line1);
            var line2 = new Line(v8, v7);
            fun.drawBline(dxf, line2, 0.2, contour);
            var line3 = new Line(v6, v5);
            fun.drawBline(dxf, line3, 0.2, contour);
            var line4 = new Line(v12, v17);
            fun.drawBline(dxf, line4, 0.2, contour);
            var line5 = new Line(v14, v11);
            fun.drawBline(dxf, line5, 0.2, contour);

            var hatchpoly1 = Pus.AddPointsToLwPolyLine(v1, v2, v0p, v0, v1);
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, -45, 80, hline1, harc1, contour);

            var hatchpoly2 = Pus.AddPointsToLwPolyLine(v8, v7, v5, v6, v8);
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 20, hline2, harc2, hatching);

            var v21 = fun.Polar(v20, 0, 1.5 * D);
            var v22 = fun.Polar(v21, pi, 0.6 * D);
            var v23 = fun.Polar(v21, 0, 0.6 * D);
            var v24 = fun.Polar(v21, 90 * pi / 180, 0.6 * D);
            var v25 = fun.Polar(v21, -90 * pi / 180, 0.6 * D);
            Line line6 = new Line(v22, v23);
            line6.Layer = centre;
            line6.Lineweight = Lineweight.W25;
            line6.Linetype = Linetype.DashDot;
            dxf.AddEntity(line6);
            Line line7 = new Line(v24, v25);
            line7.Layer = centre;
            line7.Lineweight = Lineweight.W25;
            line7.Linetype = Linetype.DashDot;
            dxf.AddEntity(line7);
            var polyline7 = Pus.AddPointsToLwPolyLine(fun.Polar(v21, pi, D / 2), fun.Polar(v21, 0, D / 2), fun.Polar(v21, pi, D / 2));
            polyline7.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
            polyline7.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
            fun.PolyFill(dxf, polyline7, 0.2, contour);
            var v26 = new Vector2(v21.X, v7.Y);
            var v27 = fun.Polar(v26, pi, 0.0487 * D);
            var v28 = fun.Polar(v26, 0, 0.0487 * D);
            var v29 = new Vector2(v21.X - fun.CalDistance(v27, v26), v21.Y - (Math.Sqrt(Math.Pow(0.1855 * D, 2) - Math.Pow(fun.CalDistance(v27, v26), 2))));
            var v30 = fun.mirrorpoint(v29, v21, v26);
            var v31 = new Vector2(v21.X - fun.CalDistance(v27, v26), v21.Y - (Math.Sqrt(Math.Pow(0.1516 * D, 2) - Math.Pow(fun.CalDistance(v27, v26), 2))));
            var v32 = fun.mirrorpoint(v31, v21, v26);

            var polyline8 = Pus.AddPointsToLwPolyLine(v29, v30);
            polyline8.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v21, v30) - fun.CalAngle(v21, v29))) / 4);
            fun.PolyFill(dxf, polyline8, 0.2, contour);
            var polyline9 = Pus.AddPointsToLwPolyLine(v31, v32, v28, v27, v31);
            polyline9.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v21, v32) - fun.CalAngle(v21, v31))) / 4);
            fun.PolyFill(dxf, polyline9, 0.2, contour);

            var v34 = fun.Polar(v21, 90 * pi / 180, D / 2);
            var v35 = fun.Polar(v21, 38 * pi / 180, 0.3425 * D);
            var v36 = fun.Polar(v21, 45 * pi / 180, D / 2);
            var v37 = fun.Polar(v21, -7 * pi / 180, 0.3425 * D);
            var v38 = fun.Polar(v21, 0 * pi / 180, D / 2);
            var v39 = fun.Polar(v21, -52 * pi / 180, 0.3425 * D);
            var v40 = fun.Polar(v21, -45 * pi / 180, D / 2);
            var v41 = fun.Polar(v21, -97 * pi / 180, 0.3425 * D);
            var v42 = fun.Polar(v21, -90 * pi / 180, D / 2);
            var v43 = fun.Polar(v21, -142 * pi / 180, 0.3425 * D);
            var v44 = fun.Polar(v21, -135 * pi / 180, D / 2);
            var v45 = fun.Polar(v21, 173 * pi / 180, 0.3425 * D);
            var v46 = fun.Polar(v21, 180 * pi / 180, D / 2);
            var v47 = fun.Polar(v21, 128 * pi / 180, 0.3425 * D);
            var v48 = fun.Polar(v21, 135 * pi / 180, D / 2);
            var v33 = fun.Polar(v21, 83 * pi / 180, 0.3425 * D);


            var polyline10 = Pus.AddPointsToLwPolyLine(v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v33, v34);
            polyline10.Vertexes[0].Bulge = -Math.Tan(54 * pi / 180 / 4);
            polyline10.Vertexes[1].Bulge = Math.Tan(35 * pi / 180 / 4);
            polyline10.Vertexes[2].Bulge = -Math.Tan(54 * pi / 180 / 4);
            polyline10.Vertexes[3].Bulge = Math.Tan(35 * pi / 180 / 4);
            polyline10.Vertexes[4].Bulge = -Math.Tan(54 * pi / 180 / 4);
            polyline10.Vertexes[5].Bulge = Math.Tan(35 * pi / 180 / 4);
            polyline10.Vertexes[6].Bulge = -Math.Tan(54 * pi / 180 / 4);
            polyline10.Vertexes[7].Bulge = Math.Tan(35 * pi / 180 / 4);
            polyline10.Vertexes[8].Bulge = -Math.Tan(54 * pi / 180 / 4);
            polyline10.Vertexes[9].Bulge = Math.Tan(35 * pi / 180 / 4);
            polyline10.Vertexes[10].Bulge = -Math.Tan(54 * pi / 180 / 4);
            polyline10.Vertexes[11].Bulge = Math.Tan(35 * pi / 180 / 4);
            polyline10.Vertexes[12].Bulge = -Math.Tan(54 * pi / 180 / 4);
            polyline10.Vertexes[13].Bulge = Math.Tan(35 * pi / 180 / 4);
            polyline10.Vertexes[14].Bulge = -Math.Tan(54 * pi / 180 / 4);
            polyline10.Vertexes[15].Bulge = Math.Tan(35 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline10, 0.2, contour);



            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度


            fun.dimrot1(dxf, v1, v4, 90, offset * 2, 0, height, arrowsize, exline, "DC=" + D, "", "");
            fun.dimrot1(dxf, v3, v4, 180, offset * 2, 0, height, arrowsize, exline, "CWN=" + L, "", "");
            fun.dimrot1(dxf, fun.Polar(v21, pi, 0.1516 * D), fun.Polar(v21, 0, 0.1516 * D), 0, D, 0, height, arrowsize, exline, "DCON=" + d, "", "");




            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard6119(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            var d = 50.0;//切削直径
            try
            {
                d = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var D = 16.0;//连接直径
            try
            {
                D = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[D] not found");
            }
            var d1 = 27.0;//轮廓直径
            try
            {
                d1 = Convert.ToDouble(data["dhub"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var L = 10.0;//切削宽度
            try
            {
                L = Convert.ToDouble(data["cw"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var chixing = 1.0;//齿型（0为直齿，1为错齿）
            try
            {
                chixing = Convert.ToDouble(data["chixing"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[chixing] not found");
            }

            var nt = 12.0;//齿数
            try
            {
                nt = Convert.ToDouble(data["nt"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[nt] not found");
            }

            var c = nt % 2;

            var γ = 360 / nt;
            var β = 360 / nt * 2;

            if (chixing == 0)
            {
                //坐标
                var v1 = new Vector2(0, 0);
                var v2 = fun.Polar(v1, pi, 62);
                var v3 = fun.Polar(v1, 0, 62);
                var v4 = fun.Polar(v1, 90 * pi / 180, 62);
                var v5 = fun.Polar(v1, -90 * pi / 180, 62);
                var v6 = fun.Polar(v1, -90 * pi / 180, 19.7);
                var v7 = fun.Polar(v6, pi, 3.94);
                var v8 = fun.Polar(v6, 0, 3.94);
                var v9 = new Vector2(v1.X - 3.94, v1.Y - (Math.Sqrt(Math.Pow(16.84, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
                var v10 = fun.mirrorpoint(v9, v1, v4);
                var v11 = new Vector2(v1.X - 3.94, v1.Y - (Math.Sqrt(Math.Pow(13.12, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
                var v12 = fun.mirrorpoint(v11, v1, v4);
                var a1 = fun.Polar(v1, 90 * pi / 180, 53);
                var a2 = fun.Polar(v1, (90 - γ * 4.0 / 36) * pi / 180, 53);
                var a3 = fun.Polar(v1, (90 - γ * 5.0 / 36) * pi / 180, 44.75);
                var a4 = fun.Polar(a3, fun.CalAngle(a1, a2), fun.CalDistance(a1, a2));
                var a5 = fun.Polar(v1, (90 - γ * 25.0 / 36) * pi / 180, 43);
                var a6 = fun.Polar(a5, fun.CalAngle(a4, a2), fun.CalDistance(a4, a2) * 3.0 / 4);
                var a7 = fun.Polar(a6, fun.CalAngle(a5, a4), fun.CalDistance(a5, a4));
                var a8 = fun.Polar(v1, (90 - γ * 25.0 / 36 + γ) * pi / 180, 43);
                var v45 = fun.Polar(v2, pi, 50);
                var v46 = fun.Polar(v45, pi, 25.5);
                var v47 = fun.Polar(v45, 90 * pi / 180, 55.81);
                var v48 = fun.Polar(v47, -90 * pi / 180, 2.78);
                var v49 = fun.Polar(v48, 223 * pi / 180, 4.84);
                var v50 = fun.Polar(v48, -90 * pi / 180, 4.72);
                var v51 = new Vector2(v49.X, v50.Y);
                var v52 = fun.Polar(v50, 218 * pi / 180, 4.04);
                var v54 = fun.Polar(v50, -90 * pi / 180, 16.83);
                var v55 = fun.Polar(v54, pi, 6);
                var v53 = fun.Polar(v55, 90 * pi / 180, 6.3);
                var v56 = fun.Polar(v54, 240 * pi / 180, 5.7);
                var v57 = fun.Polar(v56, 251 * pi / 180, 11.44);
                var v58 = new Vector2(v57.X, v45.Y);
                var v59 = fun.Polar(v45, pi, 4.5);
                var v60 = fun.Polar(v59, -90 * pi / 180, 12.12);
                var v61 = fun.Polar(v45, -90 * pi / 180, 20.15);
                var v62 = fun.Polar(v61, -90 * pi / 180, 9.65);
                var v63 = fun.Polar(v62, pi, 4.11);
                var v64 = fun.Polar(v62, pi, 7.21);
                var v65 = fun.Polar(v63, -90 * pi / 180, 9.31);
                var v66 = new Vector2(v64.X, v65.Y);
                var v67 = fun.mirrorpoint(v47, v45, v46);
                var v68 = fun.Polar(v47, pi, fun.CalDistance(v46, v45) / 2);
                var v69 = new Vector2(v68.X, v67.Y);
                var v47p = fun.mirrorpoint(v47, v68, v69);
                var v48p = fun.mirrorpoint(v48, v68, v69);
                var v49p = fun.mirrorpoint(v49, v68, v69);
                var v50p = fun.mirrorpoint(v50, v68, v69);
                var v51p = fun.mirrorpoint(v51, v68, v69);
                var v52p = fun.mirrorpoint(v52, v68, v69);
                var v53p = fun.mirrorpoint(v53, v68, v69);
                var v54p = fun.mirrorpoint(v54, v68, v69);
                var v55p = fun.mirrorpoint(v55, v68, v69);
                var v56p = fun.mirrorpoint(v56, v68, v69);
                var v57p = fun.mirrorpoint(v57, v68, v69);
                var v58p = fun.mirrorpoint(v58, v68, v69);
                var v59p = fun.mirrorpoint(v59, v68, v69);
                var v60p = fun.mirrorpoint(v60, v68, v69);
                var v61p = fun.mirrorpoint(v61, v68, v69);
                var v62p = fun.mirrorpoint(v62, v68, v69);
                var v63p = fun.mirrorpoint(v63, v68, v69);
                var v64p = fun.mirrorpoint(v64, v68, v69);
                var v65p = fun.mirrorpoint(v65, v68, v69);
                var v66p = fun.mirrorpoint(v66, v68, v69);
                var v67p = fun.mirrorpoint(v67, v68, v69);
                var v70 = fun.Polar(v45, 0, 10);
                var v71 = fun.Polar(v46, pi, 10);


                Line line1 = new Line(v2, v3);
                line1.Layer = centre;
                line1.Lineweight = Lineweight.W25;
                line1.Linetype = Linetype.DashDot;
                dxf.AddEntity(line1);
                Line line2 = new Line(v4, v5);
                line2.Layer = centre;
                line2.Lineweight = Lineweight.W25;
                line2.Linetype = Linetype.DashDot;
                dxf.AddEntity(line2);
                Line line3 = new Line(v71, v70);
                line3.Layer = centre;
                line3.Lineweight = Lineweight.W25;
                line3.Linetype = Linetype.DashDot;
                dxf.AddEntity(line3);
                var polyline1 = Pus.AddPointsToLwPolyLine(v9, v10);
                polyline1.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v1, v10) - fun.CalAngle(v1, v9))) / 4);
                fun.PolyFill(dxf, polyline1, 0.2, contour);
                var polyline2 = Pus.AddPointsToLwPolyLine(v11, v12, v8, v7, v11);
                polyline2.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v1, v12) - fun.CalAngle(v1, v11))) / 4);
                fun.PolyFill(dxf, polyline2, 0.2, contour);
                var polyline3 = Pus.AddPointsToLwPolyLine(fun.Polar(v1, pi, 28.68), fun.Polar(v1, 0, 28.68), fun.Polar(v1, pi, 28.68));
                polyline3.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                polyline3.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                fun.PolyFill(dxf, polyline3, 0.2, contour);

                LwPolyline[] linepoarray4 = new LwPolyline[100];
                var polyline4 = Pus.AddPointsToLwPolyLine(a7, a6, a5, a4, a3, a1, a2, a4);
                linepoarray4 = fun.arrayrpolyline(polyline4, nt);
                for (int i = 1; i <= nt; i++)
                {
                    fun.PolyFill(dxf, linepoarray4[i], 0.2, contour);
                }
                ;
                LwPolyline[] linepoarray5 = new LwPolyline[100];
                var polyline5 = Pus.AddPointsToLwPolyLine(a8, a3);
                polyline5.Vertexes[0].Bulge = Math.Tan(105 * Math.PI / 180 / 4);
                linepoarray5 = fun.arrayrpolyline(polyline5, nt);
                for (int i = 1; i <= nt; i++)
                {
                    fun.PolyFill(dxf, linepoarray5[i], 0.2, contour);
                }
                ;


                var polyline14 = Pus.AddPointsToLwPolyLine(v47, v67, v67p, v47p, v47);
                fun.PolyFill(dxf, polyline14, 0.2, contour);
                var polyline15 = Pus.AddPointsToLwPolyLine(v51, v49, v48, v48p, v49p, v51p);
                fun.PolyFill(dxf, polyline15, 0.2, contour);
                var polyline16 = Pus.AddPointsToLwPolyLine(v55, v53, v52, v50, v50p, v52p, v53p, v55p);
                fun.PolyFill(dxf, polyline16, 0.2, contour);
                var polyline17 = Pus.AddPointsToLwPolyLine(v58, v57, v56, v54, v54p, v56p, v57p, v58p);
                fun.PolyFill(dxf, polyline17, 0.2, contour);
                var polyline18 = Pus.AddPointsToLwPolyLine(v59, v60, v61, v61p, v60p, v59p);
                fun.PolyFill(dxf, polyline18, 0.2, contour);
                var polyline19 = Pus.AddPointsToLwPolyLine(v67, v65, v65p, v67p);
                fun.PolyFill(dxf, polyline19, 0.2, contour);
                var polyline20 = Pus.AddPointsToLwPolyLine(v62, v64, v66);
                fun.PolyFill(dxf, polyline20, 0.2, contour);
                var polyline21 = Pus.AddPointsToLwPolyLine(v62p, v64p, v66p);
                fun.PolyFill(dxf, polyline21, 0.2, contour);

                var line4 = new Line(v49, v49p);
                fun.drawBline(dxf, line4, 0.2, contour);
                var line5 = new Line(v52, v52p);
                fun.drawBline(dxf, line5, 0.2, contour);
                var line6 = new Line(v53, v53p);
                fun.drawBline(dxf, line6, 0.2, contour);
                var line7 = new Line(v56, v56p);
                fun.drawBline(dxf, line7, 0.2, contour);
                var line8 = new Line(v57, v57p);
                fun.drawBline(dxf, line8, 0.2, contour);
                var line9 = new Line(v63, v65);
                fun.drawBline(dxf, line9, 0.2, contour);
                var line10 = new Line(v63p, v65p);
                fun.drawBline(dxf, line10, 0.2, contour);
                var line11 = new Line(v60, v60p);
                fun.drawBline(dxf, line11, 0.2, contour);


                var hatchpoly1 = Pus.AddPointsToLwPolyLine(v61, v62, v64, v66, v66p, v64p, v62p, v61p, v61);
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, -45, 15, hline1, harc1, hatching);


                var height = 2.5;//字体高度
                var offset = 10;//偏移量
                var arrowsize = 1;//箭头大小
                var exline = 1;//延伸线长度


                fun.dimrot1(dxf, v47p, v67p, 90, offset * 3, 0, height, arrowsize, exline, "DC=" + d, "", "");
                fun.dimrot1(dxf, v47, v47p, 0, offset * 3, 0, height, arrowsize, exline, "CW=" + L, "", "");
                fun.dimrot1(dxf, fun.Polar(v1, pi, 13.12), fun.Polar(v1, 0, 13.12), 0, 70, 0, height, arrowsize, exline, "DCON=" + d, "", "");
                fun.Singlearrow(dxf, v62p, 180, offset, 90, 50, arrowsize, exline, height, 0, "DHUB=" + d1, "", "");
            }
            if (chixing == 1 && c == 0)
            {
                var v1 = new Vector2(0, 0);
                var v2 = fun.Polar(v1, pi, 59.5);
                var v3 = fun.Polar(v1, 0, 59.5);
                var v4 = fun.Polar(v1, 90 * pi / 180, 59.5);
                var v5 = fun.Polar(v1, -90 * pi / 180, 59.5);
                var v6 = fun.Polar(v1, -90 * pi / 180, 19.5);
                var v7 = fun.Polar(v6, pi, 3.46);
                var v8 = fun.Polar(v6, 0, 3.46);
                var v9 = new Vector2(v1.X - 3.46, v1.Y - (Math.Sqrt(Math.Pow(18.26, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
                var v10 = new Vector2(v1.X + 3.46, v1.Y - (Math.Sqrt(Math.Pow(18.26, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
                var v11 = new Vector2(v1.X - 3.46, v1.Y - (Math.Sqrt(Math.Pow(15.5, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
                var v12 = new Vector2(v1.X + 3.46, v1.Y - (Math.Sqrt(Math.Pow(15.5, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));

                var a1 = fun.Polar(v1, 90 * pi / 180, 50);
                var a2 = fun.Polar(v1, (90 - β * 3.0 / 60) * pi / 180, 37.62);
                var a3 = fun.Polar(v1, (90 - β * 10.0 / 60) * pi / 180, 50);
                var a4 = fun.Polar(v1, (90 - β * 31.0 / 60) * pi / 180, 42);
                var a5 = fun.Polar(v1, (90 - β * 43 / 60) * pi / 180, 37.62);
                var a7 = fun.Polar(v1, (90 - β * 7 / 60) * pi / 180, 37.62);
                var a6 = fun.Polar(a1, fun.CalAngle(a1, a4), fun.CalDistance(a1, a4) * 3.5 / 25.75);
                var a8 = fun.Polar(a1, fun.CalAngle(a1, a4), fun.CalDistance(a1, a4) * 15.35 / 25.75);
                var a9 = fun.Polar(v1, (90 - β * 15 / 60) * pi / 180, 37.62);
                var a10 = fun.Polar(a4, fun.CalAngle(a4, a5), fun.CalDistance(a4, a5) * 1.0 / 3);
                var a11 = fun.Polar(v1, (90 - β * 34.0 / 60) * pi / 180, 50);
                var a12 = fun.Polar(v1, (90 - β * 41.0 / 60) * pi / 180, 50);
                var a13 = fun.Polar(a10, fun.CalAngle(a11, a12), fun.CalDistance(a11, a12));
                var a14 = fun.Polar(v1, (90 - β * 51.0 / 60) * pi / 180, 46.75);
                var a15 = fun.Polar(v1, (90 - β * 59.0 / 60) * pi / 180, 40.5);
                var a1p = fun.Polar(v1, 30 * pi / 180, 50);
                var a2p = fun.Polar(v1, (30 - β * 3.0 / 60) * pi / 180, 37.62);
                var a16 = fun.Polar(a1p, fun.CalAngle(a1p, a2p), fun.CalDistance(a1p, a2p) * 2.0 / 5);

                var v55 = fun.Polar(v1, pi, 85);
                var v56 = fun.Polar(v55, pi, 19.95);
                var v57 = fun.Polar(v55, 90 * pi / 180, 50.77);
                var v58 = fun.Polar(v56, 90 * pi / 180, 50.77);
                var v59 = fun.Polar(v57, pi, 4);
                var v60 = fun.Polar(v57, -90 * pi / 180, 14);
                var v61 = fun.Polar(v59, -90 * pi / 180, 13.12);
                var v62 = fun.Polar(v59, -90 * pi / 180, 2.78);
                var v63 = fun.Polar(v62, pi, 6.29);
                var v65 = fun.Polar(v62, -90 * pi / 180, 4.75);
                var v64 = fun.Polar(v65, pi, 12.42);
                var v66 = new Vector2(v64.X, v61.Y);
                var v67 = fun.Polar(v66, -90 * pi / 180, 3.8);
                var v68 = fun.Polar(v61, -90 * pi / 180, 11.44);
                var v69 = fun.Polar(v67, -90 * pi / 180, 4.48);
                var v70 = fun.Polar(v69, -90 * pi / 180, 6.38);
                var v71 = fun.Polar(v68, -90 * pi / 180, 5.61);
                var v72 = fun.Polar(v58, -90 * pi / 180, 30.90);
                var v73 = fun.Polar(v71, -90 * pi / 180, 1.67);
                var v74 = fun.Polar(v70, -90 * pi / 180, 10.57);
                var v75 = fun.Polar(v73, -90 * pi / 180, 5);
                var v77 = fun.Polar(v57, -90 * pi / 180, 44.17);
                var v76 = fun.Polar(v74, -90 * pi / 180, 8.92);
                var v78 = fun.Inters(v73, v75, v76, v77);
                var v79 = new Vector2(v76.X, v56.Y);
                var v80 = fun.Polar(v77, -90 * pi / 180, 2.9);
                var v81 = fun.Polar(v55, pi, fun.CalDistance(v56, v79));
                var v82 = fun.Polar(v79, -90 * pi / 180, 16.35);
                var v83 = new Vector2(v81.X, v82.Y);
                var v84 = fun.Polar(v56, -90 * pi / 180, 20.2);
                var v85 = new Vector2(v55.X, v84.Y);
                var v84p = fun.Polar(v84, -90 * pi / 180, 0.85);
                var v85p = fun.Polar(v85, -90 * pi / 180, 0.85);
                var v86 = fun.Polar(v84p, -90 * pi / 180, 6);
                var v87 = fun.Polar(v86, 0, 2.8);
                var v88 = fun.Polar(v86, 0, 5.6);
                var v89 = fun.Polar(v88, -90 * pi / 180, 11.27);
                var v90 = fun.Polar(v89, 290 * pi / 180, 5.4);
                var v91 = fun.mirrorpoint(v90, fun.Polar(v55, pi, fun.CalDistance(v55, v56) / 2), fun.Polar(fun.Polar(v55, pi, fun.CalDistance(v55, v56) / 2), -90 * pi / 180, 1));
                var v92 = fun.mirrorpoint(v89, fun.Polar(v55, pi, fun.CalDistance(v55, v56) / 2), fun.Polar(fun.Polar(v55, pi, fun.CalDistance(v55, v56) / 2), -90 * pi / 180, 1));
                var v93 = fun.mirrorpoint(v88, fun.Polar(v55, pi, fun.CalDistance(v55, v56) / 2), fun.Polar(fun.Polar(v55, pi, fun.CalDistance(v55, v56) / 2), -90 * pi / 180, 1));
                var v94 = fun.mirrorpoint(v87, fun.Polar(v55, pi, fun.CalDistance(v55, v56) / 2), fun.Polar(fun.Polar(v55, pi, fun.CalDistance(v55, v56) / 2), -90 * pi / 180, 1));
                var v95 = fun.mirrorpoint(v86, fun.Polar(v55, pi, fun.CalDistance(v55, v56) / 2), fun.Polar(fun.Polar(v55, pi, fun.CalDistance(v55, v56) / 2), -90 * pi / 180, 1));
                var v96 = fun.Polar(v87, -90 * pi / 180, 10.62);
                var v97 = fun.Polar(v94, -90 * pi / 180, 10.62);
                var v98 = fun.mirrorpoint(v58, v56, v55);
                var v99 = fun.mirrorpoint(v57, v56, v55);
                var v100 = fun.Polar(v55, 0, 10);
                var v101 = fun.Polar(v56, pi, 10);

                Line line1 = new Line(v2, v3);
                line1.Layer = centre;
                line1.Lineweight = Lineweight.W25;
                line1.Linetype = Linetype.DashDot;
                dxf.AddEntity(line1);
                Line line2 = new Line(v4, v5);
                line2.Layer = centre;
                line2.Lineweight = Lineweight.W25;
                line2.Linetype = Linetype.DashDot;
                dxf.AddEntity(line2);
                Line line3 = new Line(v100, v101);
                line3.Layer = centre;
                line3.Lineweight = Lineweight.W25;
                line3.Linetype = Linetype.DashDot;
                dxf.AddEntity(line3);


                var polyline1 = Pus.AddPointsToLwPolyLine(v9, v10);
                polyline1.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v1, v10) - fun.CalAngle(v1, v9))) / 4);
                fun.PolyFill(dxf, polyline1, 0.2, contour);
                var polyline2 = Pus.AddPointsToLwPolyLine(v11, v12, v8, v7, v11);
                polyline2.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v1, v12) - fun.CalAngle(v1, v11))) / 4);
                fun.PolyFill(dxf, polyline2, 0.2, contour);
                var polyline3 = Pus.AddPointsToLwPolyLine(fun.Polar(v1, pi, 25.45), fun.Polar(v1, 0, 25.45), fun.Polar(v1, pi, 25.45));
                polyline3.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                polyline3.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                fun.PolyFill(dxf, polyline3, 0.2, contour);
                var polyline4 = Pus.AddPointsToLwPolyLine(fun.Polar(v1, pi, 37.62), fun.Polar(v1, 0, 37.62), fun.Polar(v1, pi, 37.62));
                polyline4.Vertexes[0].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                polyline4.Vertexes[1].Bulge = Math.Tan(180 * Math.PI / 180 / 4);
                fun.PolyFill(dxf, polyline4, 0.2, contour);



                LwPolyline[] linepoarray5 = new LwPolyline[100];
                var polyline5 = Pus.AddPointsToLwPolyLine(a2, a1, a3, a4, a5);
                linepoarray5 = fun.arrayrpolyline(polyline5, nt / 2);
                for (int i = 1; i <= nt / 2; i++)
                {
                    fun.PolyFill(dxf, linepoarray5[i], 0.2, contour);
                }
                ;
                LwPolyline[] linepoarray6 = new LwPolyline[100];
                var polyline6 = Pus.AddPointsToLwPolyLine(a1, a4);
                linepoarray6 = fun.arrayrpolyline(polyline6, nt / 2);
                for (int i = 1; i <= nt / 2; i++)
                {
                    fun.PolyFill(dxf, linepoarray6[i], 0.2, contour);
                }
                ;
                LwPolyline[] linepoarray7 = new LwPolyline[100];
                var polyline7 = Pus.AddPointsToLwPolyLine(a6, a7);
                linepoarray7 = fun.arrayrpolyline(polyline7, nt / 2);
                for (int i = 1; i <= nt / 2; i++)
                {
                    fun.PolyFill(dxf, linepoarray7[i], 0.2, contour);
                }
                ;
                LwPolyline[] linepoarray8 = new LwPolyline[100];
                var polyline8 = Pus.AddPointsToLwPolyLine(a9, a8);
                linepoarray8 = fun.arrayrpolyline(polyline8, nt / 2);
                for (int i = 1; i <= nt / 2; i++)
                {
                    fun.PolyFill(dxf, linepoarray8[i], 0.2, contour);
                }
                ;
                LwPolyline[] linepoarray9 = new LwPolyline[100];
                var polyline9 = Pus.AddPointsToLwPolyLine(a12, a11, a10, a13, a12, a14, a15, a16);
                linepoarray9 = fun.arrayrpolyline(polyline9, nt / 2);
                for (int i = 1; i <= nt / 2; i++)
                {
                    fun.PolyFill(dxf, linepoarray9[i], 0.2, contour);
                }
                ;


                var polyline13 = Pus.AddPointsToLwPolyLine(v58, v57, v99, v98, v58);
                fun.PolyFill(dxf, polyline13, 0.2, contour);
                var polyline14 = Pus.AddPointsToLwPolyLine(v59, v61, v60, v67);
                fun.PolyFill(dxf, polyline14, 0.2, contour);
                var polyline15 = Pus.AddPointsToLwPolyLine(v62, v63, v58, v64, v70, v72, v74, v79);
                fun.PolyFill(dxf, polyline15, 0.2, contour);
                var polyline16 = Pus.AddPointsToLwPolyLine(v60, v68, v78);
                fun.PolyFill(dxf, polyline16, 0.2, contour);
                var polyline17 = Pus.AddPointsToLwPolyLine(v79, v82, v84, v85, v83, v81, v80);
                fun.PolyFill(dxf, polyline17, 0.2, contour);
                var polyline18 = Pus.AddPointsToLwPolyLine(v86, v88, v89, v90, v91, v92, v93, v95);
                fun.PolyFill(dxf, polyline18, 0.2, contour);
                var polyline19 = Pus.AddPointsToLwPolyLine(v87, v96, v98);
                fun.PolyFill(dxf, polyline19, 0.2, contour);
                var polyline20 = Pus.AddPointsToLwPolyLine(v94, v97, v99);
                fun.PolyFill(dxf, polyline20, 0.2, contour);

                var line10 = new Line(v64, v65);
                fun.drawBline(dxf, line10, 0.2, contour);
                var line11 = new Line(v66, v61);
                fun.drawBline(dxf, line11, 0.2, contour);
                var line12 = new Line(v69, v68);
                fun.drawBline(dxf, line12, 0.2, contour);
                var line13 = new Line(v70, v71);
                fun.drawBline(dxf, line13, 0.2, contour);
                var line14 = new Line(v72, v73);
                fun.drawBline(dxf, line14, 0.2, contour);
                var line15 = new Line(v74, v75);
                fun.drawBline(dxf, line15, 0.2, contour);
                var line16 = new Line(v76, v77);
                fun.drawBline(dxf, line16, 0.2, contour);
                var line17 = new Line(v79, v80);
                fun.drawBline(dxf, line17, 0.2, contour);

                var hatchpoly1 = Pus.AddPointsToLwPolyLine(v84, v86, v88, v89, v90, v91, v92, v93, v95, v85, v84);
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 20, hline1, harc1, hatching);

                var height = 2.5;//字体高度
                var offset = 10;//偏移量
                var arrowsize = 1;//箭头大小
                var exline = 1;//延伸线长度


                fun.dimrot1(dxf, v58, v98, 90, offset * 3, 0, height, arrowsize, exline, "DC=" + d, "", "");
                fun.dimrot1(dxf, v57, v58, 0, offset * 3, 0, height, arrowsize, exline, "CW=" + L, "", "");
                fun.dimrot1(dxf, fun.Polar(v1, pi, 15.5), fun.Polar(v1, 0, 15.5), 0, 70, 0, height, arrowsize, exline, "DCON=" + d, "", "");
                fun.Singlearrow(dxf, v86, 180, offset, 90, 50, arrowsize, exline, height, 0, "DHUB=" + d1, "", "");

            }

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard1124_1_1(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            var d = 50.0;//切削直径
            try
            {
                d = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var D = 16.0;//连接直径
            try
            {
                D = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[D] not found");
            }
            var R = 27.0;//轮廓半径
            try
            {
                R = Convert.ToDouble(data["prfrad"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[R] not found");
            }
            var L = 10.0;//切削宽度
            try
            {
                L = Convert.ToDouble(data["cw"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var nt = 12.0;//齿数
            try
            {
                nt = Convert.ToDouble(data["nt"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[nt] not found");
            }
            var c = nt % 2;

            var γ = 360 / nt;
            //坐标
            var v1 = new Vector2(0, 0);
            var v2 = fun.Polar(v1, pi, 60);
            var v3 = fun.Polar(v1, 0, 60);
            var v4 = fun.Polar(v1, 90 * pi / 180, 60);
            var v5 = fun.Polar(v1, -90 * pi / 180, 60);
            var v6 = fun.Polar(v1, -90 * pi / 180, 21.96);
            var v7 = fun.Polar(v6, pi, 3.11);
            var v8 = fun.Polar(v6, 0, 3.11);
            var v9 = new Vector2(v1.X - 3.11, v1.Y - (Math.Sqrt(Math.Pow(20.76, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var v10 = new Vector2(v1.X + 3.11, v1.Y - (Math.Sqrt(Math.Pow(20.76, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var v11 = new Vector2(v1.X - 3.11, v1.Y - (Math.Sqrt(Math.Pow(17.3, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var v12 = new Vector2(v1.X + 3.11, v1.Y - (Math.Sqrt(Math.Pow(17.3, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var a1 = fun.Polar(v1, 90 * pi / 180, 53);
            var a2 = fun.Polar(v1, (90 - γ * 4.0 / 30) * pi / 180, 41.92);
            var a3 = fun.Polar(v1, (90 - γ * 21.0 / 30) * pi / 180, 49.4);
            var a4 = fun.Polar(v1, (90 - γ * 28.0 / 30) * pi / 180, 39.85);
            var a5 = fun.Polar(v1, (90 - γ * 4.0 / 30 - γ) * pi / 180, 41.92);
            var a6 = fun.Polar(a2, fun.CalAngle(a2, a1), fun.CalDistance(a2, a1) * 3.14 / 11.65);
            var a7 = fun.Polar(a4, fun.CalAngle(a4, a3), fun.CalDistance(a4, a3) * 2.27 / 10.98);

            var v15 = fun.Polar(v1, 154 * pi / 180, 39.7);
            var v32 = fun.Polar(v1, 28 * pi / 180, 39.7);
            var v35 = fun.Polar(v1, pi, 90);
            var v36 = fun.Polar(v35, pi, 19.29);
            var v37 = fun.Polar(v35, 90 * pi / 180, 44.67);
            var v38 = fun.Polar(v35, 90 * pi / 180, 41.05);
            var v39 = fun.Polar(v35, 90 * pi / 180, 37.58);
            var v40 = fun.Polar(v35, 90 * pi / 180, 28.73);
            var v41 = fun.Polar(v35, 90 * pi / 180, 21.79);
            var v42 = fun.Polar(v35, 90 * pi / 180, 6.78);
            var v43 = fun.Polar(v35, -90 * pi / 180, 18.56);
            var v44 = fun.Polar(v35, -90 * pi / 180, 22.37);
            var v45 = fun.Polar(v35, -90 * pi / 180, 32.3);
            var v46 = fun.Polar(v35, -90 * pi / 180, 44.67);
            var v47 = fun.Polar(v35, pi, 2.6);
            var v48 = fun.Polar(v35, pi, 6);
            var v49 = fun.Polar(v47, -90 * pi / 180, 16.17);
            var v50 = fun.Polar(v48, -90 * pi / 180, 16.17);
            var v51 = fun.Polar(v48, -90 * pi / 180, 18);
            var v52 = new Vector2(v37.X - 19.29 / 2, v37.Y + 19.29 / 2);
            var v53 = new Vector2(v46.X - 19.29 / 2, v46.Y - 19.29 / 2);
            var v37p = fun.mirrorpoint(v37, v52, v53);
            var v38p = fun.mirrorpoint(v38, v52, v53);
            var v39p = fun.mirrorpoint(v39, v52, v53);
            var v40p = fun.mirrorpoint(v40, v52, v53);
            var v41p = fun.mirrorpoint(v41, v52, v53);
            var v42p = fun.mirrorpoint(v42, v52, v53);
            var v43p = fun.mirrorpoint(v43, v52, v53);
            var v44p = fun.mirrorpoint(v44, v52, v53);
            var v45p = fun.mirrorpoint(v45, v52, v53);
            var v46p = fun.mirrorpoint(v46, v52, v53);
            var v47p = fun.mirrorpoint(v47, v52, v53);
            var v48p = fun.mirrorpoint(v48, v52, v53);
            var v49p = fun.mirrorpoint(v49, v52, v53);
            var v50p = fun.mirrorpoint(v50, v52, v53);
            var v51p = fun.mirrorpoint(v51, v52, v53);
            var v35p = fun.Polar(v35, 0, 9);
            var v36p = fun.Polar(v36, pi, 9);
            var v52p = fun.Polar(v52, 90 * pi / 180, 9);
            var v53p = fun.Polar(v53, -90 * pi / 180, 9);


            Line line1 = new Line(v2, v3);
            line1.Layer = centre;
            line1.Lineweight = Lineweight.W25;
            line1.Linetype = Linetype.DashDot;
            dxf.AddEntity(line1);
            Line line2 = new Line(v4, v5);
            line2.Layer = centre;
            line2.Lineweight = Lineweight.W25;
            line2.Linetype = Linetype.DashDot;
            dxf.AddEntity(line2);
            Line line3 = new Line(v36p, v35p);
            line3.Layer = centre;
            line3.Lineweight = Lineweight.W25;
            line3.Linetype = Linetype.DashDot;
            dxf.AddEntity(line3);
            Line line0 = new Line(v52p, v53p);
            line0.Layer = centre;
            line0.Lineweight = Lineweight.W25;
            line0.Linetype = Linetype.DashDot;
            dxf.AddEntity(line0);
            var polyline1 = Pus.AddPointsToLwPolyLine(v9, v10);
            polyline1.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v1, v10) - fun.CalAngle(v1, v9))) / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            var polyline2 = Pus.AddPointsToLwPolyLine(v11, v12, v8, v7, v11);
            polyline2.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v1, v12) - fun.CalAngle(v1, v11))) / 4);
            fun.PolyFill(dxf, polyline2, 0.2, contour);






            LwPolyline[] linepoarray3 = new LwPolyline[100];
            var polyline3 = Pus.AddPointsToLwPolyLine(a2, a1, a3, a4, a5);
            polyline3.Vertexes[1].Bulge = Math.Tan(-35 * pi / 180 / 4);
            polyline3.Vertexes[3].Bulge = Math.Tan(151 * pi / 180 / 4);
            linepoarray3 = fun.arrayrpolyline(polyline3, nt);
            for (int i = 1; i <= nt; i++)
            {
                fun.PolyFill(dxf, linepoarray3[i], 0.2, contour);
            }
            ;

            LwPolyline[] linepoarray4 = new LwPolyline[100];
            var polyline4 = Pus.AddPointsToLwPolyLine(a6, a7);
            linepoarray4 = fun.arrayrpolyline(polyline4, nt);
            for (int i = 1; i <= nt; i++)
            {
                fun.PolyFill(dxf, linepoarray4[i], 0.2, contour);
            }
            ;






            var polyline5 = Pus.AddPointsToLwPolyLine(v37, v37p, v46p, v46, v37);
            polyline5.Vertexes[0].Bulge = Math.Tan(180 * pi / 180 / 4);
            polyline5.Vertexes[2].Bulge = Math.Tan(180 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline5, 0.2, contour);

            var polyline6 = Pus.AddPointsToLwPolyLine(v38, v38p);
            polyline6.Vertexes[0].Bulge = Math.Tan(94 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline6, 0.2, contour);
            var polyline7 = Pus.AddPointsToLwPolyLine(v39, v39p);
            polyline7.Vertexes[0].Bulge = Math.Tan(94 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline7, 0.2, contour);
            var polyline8 = Pus.AddPointsToLwPolyLine(v40, v40p);
            polyline8.Vertexes[0].Bulge = Math.Tan(94 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline8, 0.2, contour);
            var polyline9 = Pus.AddPointsToLwPolyLine(v41, v41p);
            polyline9.Vertexes[0].Bulge = Math.Tan(94 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline9, 0.2, contour);
            var polyline10 = Pus.AddPointsToLwPolyLine(v42, v42p);
            polyline10.Vertexes[0].Bulge = Math.Tan(94 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline10, 0.2, contour);
            var polyline11 = Pus.AddPointsToLwPolyLine(v43, v49, v50, v51, v51p, v50p, v49p, v43p);
            fun.PolyFill(dxf, polyline11, 0.2, contour);


            var line8 = new Line(v47, v49);
            fun.drawBline(dxf, line8, 0.2, contour);
            var line9 = new Line(v48, v50);
            fun.drawBline(dxf, line9, 0.2, contour);
            var line10 = new Line(v48p, v50p);
            fun.drawBline(dxf, line10, 0.2, contour);
            var line11 = new Line(v47p, v49p);
            fun.drawBline(dxf, line11, 0.2, contour);
            var line12 = new Line(v44, v44p);
            fun.drawBline(dxf, line12, 0.2, contour);
            var line13 = new Line(v45, v45p);
            fun.drawBline(dxf, line13, 0.2, contour);

            var hatchpoly1 = Pus.AddPointsToLwPolyLine(v44, v44p, v45p, v45, v44);
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 20, hline1, harc1, hatching);


            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度


            fun.dimrot1(dxf, v52, v53, 90, offset * 3, 0, height, arrowsize, exline, "DC=" + d, "", "");
            fun.dimrot1(dxf, v46, v46p, 180, offset * 3, 0, height, arrowsize, exline, "CW=" + L, "", "");
            fun.dimrot1(dxf, fun.Polar(v1, pi, 17.3), fun.Polar(v1, 0, 17.3), 0, 70, 0, height, arrowsize, exline, "DCON=" + d, "", "");
            fun.jt1(dxf, fun.Polar(fun.Polar(v46, pi, fun.CalDistance(v35, v36) / 2), -45 * pi / 180, fun.CalDistance(v35, v36) / 2), -45, 20, 5, "R=" + R, height);



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard1124_1_2(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            var d = 50.0;//切削直径
            try
            {
                d = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var D = 16.0;//连接直径
            try
            {
                D = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[D] not found");
            }
            var R = 27.0;//轮廓半径
            try
            {
                R = Convert.ToDouble(data["prfrad"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[R] not found");
            }
            var L = 10.0;//切削宽度
            try
            {
                L = Convert.ToDouble(data["cw"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var nt = 12.0;//齿数
            try
            {
                nt = Convert.ToDouble(data["nt"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[nt] not found");
            }
            var c = nt % 2;

            var γ = 360 / nt;
            //坐标
            var v1 = new Vector2(0, 0);
            var v2 = fun.Polar(v1, pi, 60);
            var v3 = fun.Polar(v1, 0, 60);
            var v4 = fun.Polar(v1, 90 * pi / 180, 60);
            var v5 = fun.Polar(v1, -90 * pi / 180, 60);
            var v6 = fun.Polar(v1, -90 * pi / 180, 21.96);
            var v7 = fun.Polar(v6, pi, 3.11);
            var v8 = fun.Polar(v6, 0, 3.11);
            var v9 = new Vector2(v1.X - 3.11, v1.Y - (Math.Sqrt(Math.Pow(20.76, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var v10 = new Vector2(v1.X + 3.11, v1.Y - (Math.Sqrt(Math.Pow(20.76, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var v11 = new Vector2(v1.X - 3.11, v1.Y - (Math.Sqrt(Math.Pow(17.3, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var v12 = new Vector2(v1.X + 3.11, v1.Y - (Math.Sqrt(Math.Pow(17.3, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var a1 = fun.Polar(v1, 90 * pi / 180, 53);
            var a2 = fun.Polar(v1, (90 - γ * 4.0 / 30) * pi / 180, 41.92);
            var a3 = fun.Polar(v1, (90 - γ * 21.0 / 30) * pi / 180, 49.4);
            var a4 = fun.Polar(v1, (90 - γ * 28.0 / 30) * pi / 180, 39.85);
            var a5 = fun.Polar(v1, (90 - γ * 4.0 / 30 - γ) * pi / 180, 41.92);
            var a6 = fun.Polar(a2, fun.CalAngle(a2, a1), fun.CalDistance(a2, a1) * 3.14 / 11.65);
            var a7 = fun.Polar(a4, fun.CalAngle(a4, a3), fun.CalDistance(a4, a3) * 2.27 / 10.98);
            var v35 = fun.Polar(v1, pi, 90);
            var v36 = fun.Polar(v35, pi, 28.59);
            var v35p = fun.Polar(v35, 0, 5);
            var v36p = fun.Polar(v36, pi, 5);
            var v37 = fun.Polar(v35, 90 * pi / 180, 52.17);
            var v38 = fun.Polar(v37, pi, 4.46);
            var v39 = fun.Polar(v37, -90 * pi / 180, 4.78);
            var v40 = fun.Polar(v37, -90 * pi / 180, 8.38);
            var v41 = fun.Polar(v37, -90 * pi / 180, 21.79);
            var v42 = fun.Polar(v37, -90 * pi / 180, 27.4);
            var v43 = fun.Polar(v37, -90 * pi / 180, 42.25);
            var v44 = new Vector2(v38.X, v39.Y);
            var v45 = new Vector2(v38.X, v40.Y);
            var v46 = new Vector2(v38.X, v41.Y);
            var v47 = new Vector2(v38.X, v42.Y);
            var v48 = new Vector2(v38.X, v43.Y);
            var v49 = fun.Polar(v38, 232 * pi / 180, 4.38);
            var v50 = fun.Polar(v49, -90 * pi / 180, 3.58);
            var v51 = fun.Polar(v49, -90 * pi / 180, 6.47);
            var v52 = fun.Polar(v49, -90 * pi / 180, 20.08);
            var v53 = fun.Polar(v49, -90 * pi / 180, 25.55);
            var v54 = fun.Polar(v49, -90 * pi / 180, 40.57);
            var v55 = new Vector2(v48.X, v35.Y);
            var v56 = fun.Polar(v35, pi, 9.69);
            var v57 = fun.Polar(v35, -90 * pi / 180, 20.53);
            var v58 = fun.Polar(v55, -90 * pi / 180, 15.5);
            var v59 = fun.Polar(v56, -90 * pi / 180, 15.5);
            var v60 = fun.Polar(v35, -90 * pi / 180, 35.5);
            var v61 = fun.mirrorpoint(v37, v36, v35);
            var v62 = fun.Polar(v61, pi, 4.7);
            var v63 = new Vector2(v37.X - (fun.CalDistance(v35, v36) / 2), v37.Y + 5);
            var v64 = new Vector2(v37.X - (fun.CalDistance(v35, v36) / 2), v61.Y - 5);
            var v37p = fun.mirrorpoint(v37, v63, v64);
            var v38p = fun.mirrorpoint(v38, v63, v64);
            var v39p = fun.mirrorpoint(v39, v63, v64);
            var v40p = fun.mirrorpoint(v40, v63, v64);
            var v41p = fun.mirrorpoint(v41, v63, v64);
            var v42p = fun.mirrorpoint(v42, v63, v64);
            var v43p = fun.mirrorpoint(v43, v63, v64);
            var v44p = fun.mirrorpoint(v44, v63, v64);
            var v45p = fun.mirrorpoint(v45, v63, v64);
            var v46p = fun.mirrorpoint(v46, v63, v64);
            var v47p = fun.mirrorpoint(v47, v63, v64);
            var v48p = fun.mirrorpoint(v48, v63, v64);
            var v49p = fun.mirrorpoint(v49, v63, v64);
            var v50p = fun.mirrorpoint(v50, v63, v64);
            var v51p = fun.mirrorpoint(v51, v63, v64);
            var v52p = fun.mirrorpoint(v52, v63, v64);
            var v53p = fun.mirrorpoint(v53, v63, v64);
            var v54p = fun.mirrorpoint(v54, v63, v64);
            var v55p = fun.mirrorpoint(v55, v63, v64);
            var v56p = fun.mirrorpoint(v56, v63, v64);
            var v57p = fun.mirrorpoint(v57, v63, v64);
            var v58p = fun.mirrorpoint(v58, v63, v64);
            var v59p = fun.mirrorpoint(v59, v63, v64);
            var v60p = fun.mirrorpoint(v60, v63, v64);
            var v61p = fun.mirrorpoint(v61, v63, v64);
            var v62p = fun.mirrorpoint(v62, v63, v64);



            Line line1 = new Line(v2, v3);
            line1.Layer = centre;
            line1.Lineweight = Lineweight.W25;
            line1.Linetype = Linetype.DashDot;
            dxf.AddEntity(line1);
            Line line2 = new Line(v4, v5);
            line2.Layer = centre;
            line2.Lineweight = Lineweight.W25;
            line2.Linetype = Linetype.DashDot;
            dxf.AddEntity(line2);
            Line line0 = new Line(v36p, v35p);
            line0.Layer = centre;
            line0.Lineweight = Lineweight.W25;
            line0.Linetype = Linetype.DashDot;
            dxf.AddEntity(line0);
            Line line3 = new Line(v63, v64);
            line3.Layer = centre;
            line3.Lineweight = Lineweight.W25;
            line3.Linetype = Linetype.DashDot;
            dxf.AddEntity(line3);
            var polyline1 = Pus.AddPointsToLwPolyLine(v9, v10);
            polyline1.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v1, v10) - fun.CalAngle(v1, v9))) / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            var polyline2 = Pus.AddPointsToLwPolyLine(v11, v12, v8, v7, v11);
            polyline2.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v1, v12) - fun.CalAngle(v1, v11))) / 4);
            fun.PolyFill(dxf, polyline2, 0.2, contour);

            LwPolyline[] linepoarray3 = new LwPolyline[100];
            var polyline3 = Pus.AddPointsToLwPolyLine(a2, a1, a3, a4, a5);
            polyline3.Vertexes[1].Bulge = Math.Tan(-35 * pi / 180 / 4);
            polyline3.Vertexes[3].Bulge = Math.Tan(151 * pi / 180 / 4);
            linepoarray3 = fun.arrayrpolyline(polyline3, nt);
            for (int i = 1; i <= nt; i++)
            {
                fun.PolyFill(dxf, linepoarray3[i], 0.2, contour);
            }
            ;

            LwPolyline[] linepoarray4 = new LwPolyline[100];
            var polyline4 = Pus.AddPointsToLwPolyLine(a6, a7);
            linepoarray4 = fun.arrayrpolyline(polyline4, nt);
            for (int i = 1; i <= nt; i++)
            {
                linepoarray4[i].Layer = refin;
                linepoarray4[i].Lineweight = Lineweight.W35;
                linepoarray4[i].Linetype = Linetype.Dashed;
                dxf.AddEntity(linepoarray4[i]);
            }
            ;

            var polyline6 = Pus.AddPointsToLwPolyLine(v37, v38, v49, v49p, v38p, v37p, v61p, v62p, v62, v61, v37);
            polyline6.Vertexes[1].Bulge = -Math.Tan(23 * pi / 180 / 4);
            polyline6.Vertexes[2].Bulge = -Math.Tan(81 * pi / 180 / 4);
            polyline6.Vertexes[3].Bulge = -Math.Tan(23 * pi / 180 / 4);
            polyline6.Vertexes[7].Bulge = -Math.Tan(180 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline6, 0.2, contour);
            var polyline7 = Pus.AddPointsToLwPolyLine(v39, v44, v50, v50p, v44p, v39p);
            polyline7.Vertexes[1].Bulge = -Math.Tan(15 * pi / 180 / 4);
            polyline7.Vertexes[2].Bulge = -Math.Tan(65 * pi / 180 / 4);
            polyline7.Vertexes[3].Bulge = -Math.Tan(15 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline7, 0.2, contour);
            var polyline8 = Pus.AddPointsToLwPolyLine(v40, v45, v51, v51p, v45p, v40p);
            polyline8.Vertexes[1].Bulge = -Math.Tan(10 * pi / 180 / 4);
            polyline8.Vertexes[2].Bulge = -Math.Tan(50 * pi / 180 / 4);
            polyline8.Vertexes[3].Bulge = -Math.Tan(10 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline8, 0.2, contour);
            var polyline9 = Pus.AddPointsToLwPolyLine(v41, v46, v52, v52p, v46p, v41p);
            polyline9.Vertexes[1].Bulge = -Math.Tan(12 * pi / 180 / 4);
            polyline9.Vertexes[2].Bulge = -Math.Tan(54 * pi / 180 / 4);
            polyline9.Vertexes[3].Bulge = -Math.Tan(12 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline9, 0.2, contour);
            var polyline10 = Pus.AddPointsToLwPolyLine(v42, v47, v53, v53p, v47p, v42p);
            polyline10.Vertexes[1].Bulge = -Math.Tan(11 * pi / 180 / 4);
            polyline10.Vertexes[2].Bulge = -Math.Tan(51 * pi / 180 / 4);
            polyline10.Vertexes[3].Bulge = -Math.Tan(11 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline10, 0.2, contour);
            var polyline11 = Pus.AddPointsToLwPolyLine(v43, v48, v54, v54p, v48p, v43p);
            polyline11.Vertexes[1].Bulge = -Math.Tan(12 * pi / 180 / 4);
            polyline11.Vertexes[2].Bulge = -Math.Tan(55 * pi / 180 / 4);
            polyline11.Vertexes[3].Bulge = -Math.Tan(12 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline11, 0.2, contour);
            var line8 = new Line(v38, v44);
            fun.drawBline(dxf, line8, 0.2, contour);
            var line9 = new Line(v45, v46);
            fun.drawBline(dxf, line9, 0.2, contour);
            var line10 = new Line(v47, v48);
            fun.drawBline(dxf, line10, 0.2, contour);
            var line11 = new Line(v49, v50);
            fun.drawBline(dxf, line11, 0.2, contour);
            var line12 = new Line(v51, v52);
            fun.drawBline(dxf, line12, 0.2, contour);
            var line13 = new Line(v53, v54);
            fun.drawBline(dxf, line13, 0.2, contour);
            var line14 = new Line(v38p, v44p);
            fun.drawBline(dxf, line14, 0.2, contour);
            var line15 = new Line(v45p, v46p);
            fun.drawBline(dxf, line15, 0.2, contour);
            var line16 = new Line(v47p, v48p);
            fun.drawBline(dxf, line16, 0.2, contour);
            var line17 = new Line(v49p, v50p);
            fun.drawBline(dxf, line17, 0.2, contour);
            var line18 = new Line(v51p, v52p);
            fun.drawBline(dxf, line18, 0.2, contour);
            var line19 = new Line(v53p, v54p);
            fun.drawBline(dxf, line19, 0.2, contour);
            var line20 = new Line(v55, v58);
            fun.drawBline(dxf, line20, 0.2, contour);
            var line21 = new Line(v56, v59);
            fun.drawBline(dxf, line21, 0.2, contour);
            var line22 = new Line(v55p, v58p);
            fun.drawBline(dxf, line22, 0.2, contour);
            var line23 = new Line(v56p, v59p);
            fun.drawBline(dxf, line23, 0.2, contour);
            var line24 = new Line(v60, v60p);
            fun.drawBline(dxf, line24, 0.2, contour);
            var polyline12 = Pus.AddPointsToLwPolyLine(v57, v58, v59, v59p, v58p, v57p, v57);
            polyline12.Vertexes[2].Bulge = -Math.Tan(127 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline12, 0.2, contour);



            var hatchpoly1 = Pus.AddPointsToLwPolyLine(v57, v57p, v60p, v60, v57);
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 20, hline1, harc1, hatching);



            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度


            fun.dimrot1(dxf, v37p, v61p, 90, offset * 3, 0, height, arrowsize, exline, "DC=" + d, "", "");
            fun.dimrot1(dxf, v61p, new Vector2(v64.X, v62.Y + 2), 90, offset * 1.5, 0, height, arrowsize, exline, "C=" + d, "", "");
            fun.dimrot1(dxf, v61, v61p, 180, offset * 3, 0, height, arrowsize, exline, "CW=" + L, "", "");
            fun.dimrot1(dxf, fun.Polar(v1, pi, 17.3), fun.Polar(v1, 0, 17.3), 0, 70, 0, height, arrowsize, exline, "DCON=" + d, "", "");
            fun.jt1(dxf, fun.Polar(fun.Polar(v62, pi, fun.CalDistance(v62, v62p) / 2), 45 * pi / 180, fun.CalDistance(v62, v62p) / 2), 30, 20, 5, "R=" + R, height);

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard6122_1(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            var D = 50.0;//切削直径
            try
            {
                D = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[D] not found");
            }
            var d = 16.0;//连接直径
            try
            {
                d = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var R = 1.0;//轮廓半径
            try
            {
                R = Convert.ToDouble(data["prfrad"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[R] not found");
            }
            var L = 4.0;//切削宽度
            try
            {
                L = Convert.ToDouble(data["oal"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var nt = 12.0;//齿数
            try
            {
                nt = Convert.ToDouble(data["nt"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[nt] not found");
            }
            var c = nt % 2;

            var γ = 360 / nt;
            //坐标
            var v1 = new Vector2(0, 0);
            var v2 = fun.Polar(v1, pi, 60);
            var v3 = fun.Polar(v1, 0, 60);
            var v4 = fun.Polar(v1, 90 * pi / 180, 60);
            var v5 = fun.Polar(v1, -90 * pi / 180, 60);
            var v6 = fun.Polar(v1, -90 * pi / 180, 21.96);
            var v7 = fun.Polar(v6, pi, 3.11);
            var v8 = fun.Polar(v6, 0, 3.11);
            var v9 = new Vector2(v1.X - 3.11, v1.Y - (Math.Sqrt(Math.Pow(20.76, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var v10 = new Vector2(v1.X + 3.11, v1.Y - (Math.Sqrt(Math.Pow(20.76, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var v11 = new Vector2(v1.X - 3.11, v1.Y - (Math.Sqrt(Math.Pow(17.3, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var v12 = new Vector2(v1.X + 3.11, v1.Y - (Math.Sqrt(Math.Pow(17.3, 2) - Math.Pow(fun.CalDistance(v7, v6), 2))));
            var a1 = fun.Polar(v1, 90 * pi / 180, 53);
            var a2 = fun.Polar(v1, (90 - γ * 4.0 / 30) * pi / 180, 41.92);
            var a3 = fun.Polar(v1, (90 - γ * 21.0 / 30) * pi / 180, 49.4);
            var a4 = fun.Polar(v1, (90 - γ * 28.0 / 30) * pi / 180, 39.85);
            var a5 = fun.Polar(v1, (90 - γ * 4.0 / 30 - γ) * pi / 180, 41.92);
            var a6 = fun.Polar(a2, fun.CalAngle(a2, a1), fun.CalDistance(a2, a1) * 3.14 / 11.65);
            var a7 = fun.Polar(a4, fun.CalAngle(a4, a3), fun.CalDistance(a4, a3) * 2.27 / 10.98);
            var v35 = fun.Polar(v1, pi, 90);
            var v36 = fun.Polar(v35, pi, 15.68);
            var v37 = fun.Polar(v35, 90 * pi / 180, 53.6);
            var v37p = fun.Polar(v37, pi, 6.3);
            var v38 = fun.Polar(v37, -90 * pi / 180, 7.12);
            var v39 = fun.Polar(v38, pi, 4.77);
            var v40 = fun.Polar(v38, -90 * pi / 180, 4.46);
            var v41 = fun.Polar(v40, pi, 5.77);
            var v42 = fun.Polar(v35, 90 * pi / 180, 32.84);
            var v43 = fun.Polar(v42, pi, 4.61);
            var v44 = fun.Polar(v35, 90 * pi / 180, 23.86);
            var v45 = fun.Polar(v44, pi, 6.13);
            var v46 = fun.Polar(v35, 90 * pi / 180, 11.45);
            var v47 = fun.Polar(v46, pi, 4.43);
            var v48 = fun.Polar(v36, 90 * pi / 180, 44.79);
            var v49 = fun.Polar(v36, 90 * pi / 180, 41.47);
            var v50 = fun.Polar(v36, 90 * pi / 180, 37.68);
            var v51 = fun.Polar(v36, 90 * pi / 180, 27.42);
            var v52 = fun.Polar(v36, 90 * pi / 180, 21.42);
            var v53 = fun.Polar(v36, 90 * pi / 180, 9);
            var v54 = fun.Polar(v35, pi, 2.37);
            var v55 = fun.Polar(v36, 0, 2.37);
            var v56 = fun.Polar(v35, -90 * pi / 180, 18.79);
            var v57 = fun.Polar(v54, -90 * pi / 180, 14.6);
            var v58 = new Vector2(v55.X, v57.Y);
            var v59 = new Vector2(v36.X, v56.Y);
            var v60 = fun.Polar(v35, -90 * pi / 180, 36.2);
            var v60p = new Vector2(v36.X, v60.Y);
            var v62 = fun.mirrorpoint(v37, v36, v35);
            var v63 = fun.mirrorpoint(v37p, v36, v35);
            var v64 = fun.mirrorpoint(v48, v36, v35);
            var v66 = fun.Polar(v35, 0, 8);
            var v67 = fun.Polar(v36, pi, 8);


            Line line1 = new Line(v2, v3);
            line1.Layer = centre;
            line1.Lineweight = Lineweight.W25;
            line1.Linetype = Linetype.DashDot;
            dxf.AddEntity(line1);
            Line line2 = new Line(v4, v5);
            line2.Layer = centre;
            line2.Lineweight = Lineweight.W25;
            line2.Linetype = Linetype.DashDot;
            dxf.AddEntity(line2);
            Line line3 = new Line(v66, v67);
            line3.Layer = centre;
            line3.Lineweight = Lineweight.W25;
            line3.Linetype = Linetype.DashDot;
            dxf.AddEntity(line3);
            var polyline1 = Pus.AddPointsToLwPolyLine(v9, v10);
            polyline1.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v1, v10) - fun.CalAngle(v1, v9))) / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            var polyline2 = Pus.AddPointsToLwPolyLine(v11, v12, v8, v7, v11);
            polyline2.Vertexes[0].Bulge = -Math.Tan((360 * pi / 180 - (fun.CalAngle(v1, v12) - fun.CalAngle(v1, v11))) / 4);
            fun.PolyFill(dxf, polyline2, 0.2, contour);


            LwPolyline[] linepoarray3 = new LwPolyline[100];
            var polyline3 = Pus.AddPointsToLwPolyLine(a2, a1, a3, a4, a5);
            polyline3.Vertexes[1].Bulge = Math.Tan(-35 * pi / 180 / 4);
            polyline3.Vertexes[3].Bulge = Math.Tan(151 * pi / 180 / 4);
            linepoarray3 = fun.arrayrpolyline(polyline3, nt);
            for (int i = 1; i <= nt; i++)
            {
                fun.PolyFill(dxf, linepoarray3[i], 0.2, contour);
            }
            ;

            LwPolyline[] linepoarray4 = new LwPolyline[100];
            var polyline4 = Pus.AddPointsToLwPolyLine(a6, a7);
            linepoarray4 = fun.arrayrpolyline(polyline4, nt);
            for (int i = 1; i <= nt; i++)
            {
                fun.PolyFill(dxf, linepoarray4[i], 0.2, contour);
            }
            ;

            var line8 = new Line(v37p, v39);
            fun.drawBline(dxf, line8, 0.2, contour);
            var line9 = new Line(v41, v43);
            fun.drawBline(dxf, line9, 0.2, contour);
            var line10 = new Line(v45, v47);
            fun.drawBline(dxf, line10, 0.2, contour);
            var line11 = new Line(v55, v58);
            fun.drawBline(dxf, line11, 0.2, contour);
            var line12 = new Line(v54, v57);
            fun.drawBline(dxf, line12, 0.2, contour);
            var line13 = new Line(v60p, v60);
            fun.drawBline(dxf, line13, 0.2, contour);

            var polyline5 = Pus.AddPointsToLwPolyLine(v37, v37p, v48, v64, v63, v62, v37);
            polyline5.Vertexes[1].Bulge = -Math.Tan(84 * pi / 180 / 4);
            polyline5.Vertexes[3].Bulge = -Math.Tan(84 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline5, 0.2, contour);
            var polyline6 = Pus.AddPointsToLwPolyLine(v38, v39, v49);
            polyline6.Vertexes[1].Bulge = -Math.Tan(56 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline6, 0.2, contour);
            var polyline7 = Pus.AddPointsToLwPolyLine(v40, v41, v50);
            polyline7.Vertexes[1].Bulge = -Math.Tan(40 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline7, 0.2, contour);
            var polyline8 = Pus.AddPointsToLwPolyLine(v42, v43, v51);
            polyline8.Vertexes[1].Bulge = -Math.Tan(56 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline8, 0.2, contour);
            var polyline9 = Pus.AddPointsToLwPolyLine(v44, v45, v52);
            polyline9.Vertexes[1].Bulge = -Math.Tan(46 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline9, 0.2, contour);
            var polyline10 = Pus.AddPointsToLwPolyLine(v46, v47, v53);





            polyline10.Vertexes[1].Bulge = -Math.Tan(53 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline10, 0.2, contour);
            var polyline11 = Pus.AddPointsToLwPolyLine(v56, v57, v58, v59, v56);
            fun.PolyFill(dxf, polyline11, 0.2, contour);


            var hatchpoly1 = Pus.AddPointsToLwPolyLine(v59, v60p, v60, v56, v59);
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 20, hline1, harc1, hatching);




            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度



            fun.dimrot1(dxf, v37p, v63, 90, offset * 3, 0, height, arrowsize, exline, "DC=" + D, "", "");
            fun.dimrot1(dxf, v64, v62, 180, offset * 3, 0, height, arrowsize, exline, "OAL=" + L, "", "");
            fun.dimrot1(dxf, fun.Polar(v1, pi, 17.3), fun.Polar(v1, 0, 17.3), 0, 70, 0, height, arrowsize, exline, "DCON=" + d, "", "");


            var v0 = fun.Polar(v64, fun.CalAngle(v64, v63) - (90 * pi / 180 - 42 * pi / 180), (fun.CalDistance(v64, v63) / 2 / Math.Sin(42 * pi / 180)));


            fun.jt1(dxf, fun.Polar(v0, 45 * pi / 180, fun.CalDistance(v0, v64)), 30, 20, 5, "R", height);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard6128_1_1(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            var d = 40.0;//切削直径
            try
            {
                d = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var D = 16.0;//连接直径
            try
            {
                D = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[D] not found");
            }
            var θ = 45.0;//刀具切削刃角度
            try
            {
                θ = Convert.ToDouble(data["kapr"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[θ] not found");
            }
            var L = 4.0;//最小切削宽度
            try
            {
                L = Convert.ToDouble(data["cwn"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }
            var nt = 18.0;//齿数
            try
            {
                nt = Convert.ToDouble(data["nt"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[nt] not found");
            }

            var γ = 360 / nt;
            //坐标
            var v0 = new Vector2(0, 0);
            var v2 = fun.Polar(v0, 90 * pi / 180, 17.71);
            var v3 = fun.Polar(v2, pi, 3.16);
            var v4 = fun.Polar(v2, 0, 3.16);
            var v5 = new Vector2(v3.X, v0.Y + (Math.Sqrt(Math.Pow(15.61, 2) - Math.Pow(fun.CalDistance(v3, v4), 2))));
            var v6 = new Vector2(v4.X, v0.Y + (Math.Sqrt(Math.Pow(15.61, 2) - Math.Pow(fun.CalDistance(v3, v4), 2))));
            var v7 = new Vector2(v3.X, v0.Y + (Math.Sqrt(Math.Pow(11.78, 2) - Math.Pow(fun.CalDistance(v3, v4), 2))));
            var v8 = new Vector2(v4.X, v0.Y + (Math.Sqrt(Math.Pow(11.78, 2) - Math.Pow(fun.CalDistance(v3, v4), 2))));
            var v9 = fun.Polar(v0, pi, 56.23);
            var v10 = fun.Polar(v0, 0, 56.23);
            var v11 = fun.Polar(v0, 90 * pi / 180, 56.23);
            var v12 = fun.Polar(v0, -90 * pi / 180, 56.23);

            var a1 = fun.Polar(v0, 90 * pi / 180, 46);
            var a2 = fun.Polar(v0, (90 - γ * 3.0 / 20) * pi / 180, 46);
            var a3 = fun.Polar(v0, (90 - γ * 5.0 / 20) * pi / 180, 31.35);
            var a4 = fun.Polar(v0, (90 - γ * 10.0 / 20) * pi / 180, 31.35);
            var a1p = fun.Polar(v0, (90 - γ) * pi / 180, 46);
            var a3p = fun.Polar(v0, (90 - γ * 5.0 / 20 - γ) * pi / 180, 31.35);
            var a5 = fun.Polar(a3p, fun.CalAngle(a3p, a1p), fun.CalDistance(a3p, a1p) * 9.8 / 15);

            var v36 = fun.Polar(v0, pi, 135);
            var v37 = fun.Polar(v36, pi, 27.91);
            var v38 = fun.Polar(v36, 0, 10);
            var v39 = fun.Polar(v37, pi, 10);
            var v40 = fun.Polar(v36, 90 * pi / 180, 30.26);
            var v41 = fun.Polar(v37, 90 * pi / 180, 46.38);
            var v42 = fun.mirrorpoint(v41, v39, v38);
            var v43 = fun.mirrorpoint(v40, v39, v38);
            var v44 = fun.Polar(v36, 90 * pi / 180, 27.20);
            var v45 = fun.Polar(v36, 90 * pi / 180, 25.34);
            var v46 = fun.Polar(v36, 90 * pi / 180, 20.62);
            var v47 = fun.Polar(v36, 90 * pi / 180, 17.21);
            var v48 = fun.Polar(v36, 90 * pi / 180, 10.23);
            var v49 = fun.Polar(v36, 90 * pi / 180, 7.18);
            var v50 = fun.Polar(v37, 90 * pi / 180, 37.44);
            var v51 = fun.Polar(v50, fun.CalAngle(v50, v44), 3.5);
            var v53 = fun.Polar(v37, 90 * pi / 180, 24.94);
            var v54 = fun.Polar(v53, fun.CalAngle(v53, v46), 3.58);
            var v52 = fun.Inters(v50, v54, v45, fun.Polar(v45, fun.CalAngle(v44, v50), 1));
            var v56 = fun.Polar(v37, 90 * pi / 180, 12.39);
            var v57 = fun.Polar(v56, fun.CalAngle(v56, v48), 3.82);
            var v55 = fun.Inters(v53, v57, v47, fun.Polar(v47, fun.CalAngle(v46, v53), 1));
            var v59 = fun.Polar(v37, 0, 4.79);
            var v58 = fun.Inters(v56, v59, v49, fun.Polar(v49, fun.CalAngle(v48, v56), 1));
            var v60 = fun.Polar(v37, 0, 2.57);
            var v61 = fun.Polar(v37, 0, 7.19);
            var v62 = fun.Polar(v36, pi, 3.57);
            var v63 = fun.Polar(v36, -90 * pi / 180, 13.59);
            var v64 = fun.Polar(v62, -90 * pi / 180, 10.4);
            var v65 = fun.Polar(v61, -90 * pi / 180, 10.4);
            var v66 = fun.Polar(v59, -90 * pi / 180, 13.47);
            var v67 = fun.Polar(v59, -90 * pi / 180, 19.5);
            var v68 = fun.Polar(v67, 0, 2.38);
            var v69 = fun.Polar(v68, -90 * pi / 180, 10.65);
            var v70 = new Vector2(v60.X, v69.Y);
            var v71 = fun.Polar(v60, -90 * pi / 180, 33.74);
            var v72 = fun.Polar(v70, 0, 2.3);
            var v73 = fun.Polar(v72, 288 * pi / 180, 4.74);
            var v74 = fun.Polar(v36, -90 * pi / 180, 24.93);

            Line line1 = new Line(v9, v10);
            line1.Layer = centre;
            line1.Lineweight = Lineweight.W25;
            line1.Linetype = Linetype.DashDot;
            dxf.AddEntity(line1);
            Line line2 = new Line(v11, v12);
            line2.Layer = centre;
            line2.Lineweight = Lineweight.W25;
            line2.Linetype = Linetype.DashDot;
            dxf.AddEntity(line2);
            Line line3 = new Line(v39, v38);
            line3.Layer = centre;
            line3.Lineweight = Lineweight.W25;
            line3.Linetype = Linetype.DashDot;
            dxf.AddEntity(line3);
            var polyline1 = Pus.AddPointsToLwPolyLine(v5, v6);
            polyline1.Vertexes[0].Bulge = Math.Tan((360 * pi / 180 - (fun.CalAngle(v0, v5) - fun.CalAngle(v0, v6))) / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            var polyline2 = Pus.AddPointsToLwPolyLine(v7, v8, v4, v3, v7);
            polyline2.Vertexes[0].Bulge = Math.Tan((360 * pi / 180 - (fun.CalAngle(v0, v7) - fun.CalAngle(v0, v8))) / 4);
            fun.PolyFill(dxf, polyline2, 0.2, contour);

            var polyline4 = Pus.AddPointsToLwPolyLine(fun.Polar(v0, pi, 31.35), fun.Polar(v0, 0, 31.35), fun.Polar(v0, pi, 31.35));
            polyline4.Vertexes[0].Bulge = Math.Tan(180 * pi / 180 / 4);
            polyline4.Vertexes[1].Bulge = Math.Tan(180 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline4, 0.2, contour);
            var polyline5 = Pus.AddPointsToLwPolyLine(fun.Polar(v0, pi, 20.74), fun.Polar(v0, 0, 20.74), fun.Polar(v0, pi, 20.74));
            polyline5.Vertexes[0].Bulge = Math.Tan(180 * pi / 180 / 4);
            polyline5.Vertexes[1].Bulge = Math.Tan(180 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline5, 0.2, contour);
            var polyline6 = Pus.AddPointsToLwPolyLine(v40, v41, v42, v43, v40);
            fun.PolyFill(dxf, polyline6, 0.2, contour);
            var polyline7 = Pus.AddPointsToLwPolyLine(v60, v71, v42);
            fun.PolyFill(dxf, polyline7, 0.2, contour);
            var polyline8 = Pus.AddPointsToLwPolyLine(v59, v67, v68, v69, v70);
            fun.PolyFill(dxf, polyline8, 0.2, contour);
            var polyline9 = Pus.AddPointsToLwPolyLine(v66, v65, v64, v63);
            fun.PolyFill(dxf, polyline9, 0.2, contour);
            var polyline10 = Pus.AddPointsToLwPolyLine(v72, v73, v74);
            fun.PolyFill(dxf, polyline10, 0.2, contour);

            LwPolyline[] linepoarray3 = new LwPolyline[100];
            var polyline3 = Pus.AddPointsToLwPolyLine(a3, a1, a2, a4);
            linepoarray3 = fun.arrayrpolyline(polyline3, nt);
            for (int i = 1; i <= nt; i++)
            {
                fun.PolyFill(dxf, linepoarray3[i], 0.2, contour);
            }
            ;

            LwPolyline[] linepoarray4 = new LwPolyline[100];
            var polyline11 = Pus.AddPointsToLwPolyLine(a2, a5);
            linepoarray4 = fun.arrayrpolyline(polyline11, nt);
            for (int i = 1; i <= nt; i++)
            {
                fun.PolyFill(dxf, linepoarray4[i], 0.2, contour);
            }
            ;

            var line13 = new Line(v41, v51);
            fun.drawBline(dxf, line13, 0.2, contour);
            var line14 = new Line(v50, v44);
            fun.drawBline(dxf, line14, 0.2, contour);
            var line15 = new Line(v52, v45);
            fun.drawBline(dxf, line15, 0.2, contour);
            var line16 = new Line(v50, v54);
            fun.drawBline(dxf, line16, 0.2, contour);
            var line17 = new Line(v53, v46);
            fun.drawBline(dxf, line17, 0.2, contour);
            var line18 = new Line(v53, v57);
            fun.drawBline(dxf, line18, 0.2, contour);
            var line19 = new Line(v55, v47);
            fun.drawBline(dxf, line19, 0.2, contour);
            var line20 = new Line(v56, v48);
            fun.drawBline(dxf, line20, 0.2, contour);
            var line21 = new Line(v56, v59);
            fun.drawBline(dxf, line21, 0.2, contour);
            var line22 = new Line(v58, v49);
            fun.drawBline(dxf, line22, 0.2, contour);
            var line23 = new Line(v61, v65);
            fun.drawBline(dxf, line23, 0.2, contour);
            var line24 = new Line(v64, v62);
            fun.drawBline(dxf, line24, 0.2, contour);

            var hatchpoly1 = Pus.AddPointsToLwPolyLine(v63, v64, v65, v66, v67, v68, v69, v72, v73, v74, v63);
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 20, hline1, harc1, hatching);



            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度



            fun.dimrot1(dxf, fun.Polar(v0, pi, 11.78), fun.Polar(v0, 0, 11.78), 0, 70, 0, height, arrowsize, exline, "DCON=" + D, "", "");
            fun.dimrot1(dxf, v42, v43, 180, offset * 3, 0, height, arrowsize, exline, "CWN=" + L, "", "");
            fun.dimrot1(dxf, v41, v42, 90, offset * 3, 0, height, arrowsize, exline, "DC=" + d, "", "");
            fun.jdbz2(dxf, new Line(v42, v41), new Line(v40, v41), offset * 2, height, arrowsize, exline, "KAPR=" + θ + "°", "", "");

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }




            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard6128_1_2(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            var d = 40.0;//切削直径
            try
            {
                d = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var D = 13.0;//连接直径
            try
            {
                D = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[D] not found");
            }
            var θ = 55.0;//刀具切削刃角度
            try
            {
                θ = Convert.ToDouble(data["kapr"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[θ] not found");
            }
            var δ = 15.0;//刀具切削刃角度
            try
            {
                δ = Convert.ToDouble(data["kapr2"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[δ] not found");
            }
            var L = 6.0;//最小切削宽度
            try
            {
                L = Convert.ToDouble(data["cwn"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }

            var nt = 18.0;//齿数
            try
            {
                nt = Convert.ToDouble(data["nt"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[nt] not found");
            }

            var γ = 360 / nt;
            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, 90 * pi / 180, 75);
            var v2 = fun.Polar(v0, -90 * pi / 180, 75);
            var v3 = fun.Polar(v0, pi, 75);
            var v4 = fun.Polar(v0, 0, 75);
            var v5 = fun.Polar(v0, -90 * pi / 180, 27.5);
            var v6 = fun.Polar(v5, pi, 4);
            var v7 = fun.Polar(v5, 0, 4);
            var v8 = new Vector2(v6.X, v0.Y - (Math.Sqrt(Math.Pow(22.8, 2) - Math.Pow(fun.CalDistance(v6, v5), 2))));
            var v9 = new Vector2(v7.X, v0.Y - (Math.Sqrt(Math.Pow(22.8, 2) - Math.Pow(fun.CalDistance(v6, v5), 2))));
            var v10 = new Vector2(v6.X, v0.Y - (Math.Sqrt(Math.Pow(19.15, 2) - Math.Pow(fun.CalDistance(v6, v5), 2))));
            var v11 = new Vector2(v7.X, v0.Y - (Math.Sqrt(Math.Pow(19.15, 2) - Math.Pow(fun.CalDistance(v6, v5), 2))));
            var a1 = fun.Polar(v0, 90 * pi / 180, 60);
            var a2 = fun.Polar(v0, (90 - γ * 5.0 / 20) * pi / 180, 60);
            var a3 = fun.Polar(v0, (90 - γ * 3.0 / 20) * pi / 180, 45.33);
            var a4 = fun.Polar(a3, fun.CalAngle(a1, a2), fun.CalDistance(a1, a2));
            var a5 = fun.Polar(v0, (90 - γ) * pi / 180, 60);
            var a6 = fun.Polar(v0, (90 - γ * 3.0 / 20 - γ) * pi / 180, 45.33);
            var a7 = fun.Polar(v0, (90 - γ * 13.0 / 20) * pi / 180, 55.2);
            var a8 = fun.Polar(v0, (90 - γ * 17.0 / 20) * pi / 180, 44.2);

            var v51 = fun.Polar(v0, pi, 175);
            var v52 = fun.Polar(v51, pi, 40.35);
            var v53 = fun.Polar(v51, 0, 10);
            var v54 = fun.Polar(v52, pi, 10);
            var v55 = fun.Polar(v51, 90 * pi / 180, 42.12);
            var v56 = fun.Polar(v55, 150 * pi / 180, 38.33);
            var v57 = fun.Polar(v52, 90 * pi / 180, 48.82);
            var v58 = fun.mirrorpoint(v57, v52, v51);
            var v59 = fun.mirrorpoint(v56, v52, v51);
            var v60 = fun.mirrorpoint(v55, v52, v51);
            var v61 = fun.Polar(v51, 90 * pi / 180, 38.66);
            var v62 = fun.Polar(v51, 90 * pi / 180, 34.05);
            var v63 = fun.Polar(v51, 90 * pi / 180, 30.7);
            var v64 = fun.Polar(v51, 90 * pi / 180, 25.34);
            var v65 = fun.Polar(v51, 90 * pi / 180, 22.07);
            var v66 = fun.Polar(v51, 90 * pi / 180, 15.97);
            var v67 = fun.Polar(v51, 90 * pi / 180, 13);
            var v68 = fun.Polar(v51, 90 * pi / 180, 5.45);
            var v69 = fun.Polar(v51, 90 * pi / 180, 2.45);
            var v70 = fun.Polar(v52, 90 * pi / 180, 44.4);
            var v71 = fun.Polar(v52, 90 * pi / 180, 40.75);
            var v72 = fun.Polar(v52, 90 * pi / 180, 37.1);
            var v73 = fun.Polar(v52, 90 * pi / 180, 30.62);
            var v74 = fun.Polar(v52, 90 * pi / 180, 26.34);
            var v75 = fun.Polar(v52, 90 * pi / 180, 14.82);
            var v76 = fun.Polar(v52, 90 * pi / 180, 10.37);
            var v77 = fun.Polar(v52, 90 * pi / 180, 4.83);
            var v78 = fun.Polar(v52, 90 * pi / 180, 1.3);
            var v79 = fun.Polar(v61, 150 * pi / 180, 36.56);
            var v80 = fun.Polar(v62, 153 * pi / 180, 35.07);
            var v81 = fun.Polar(v63, 153 * pi / 180, 34.57);
            var v82 = fun.Polar(v64, 158 * pi / 180, 32.76);
            var v83 = fun.Polar(v65, 158 * pi / 180, 32.89);
            var v84 = fun.Polar(v66, 170 * pi / 180, 31.37);
            var v85 = fun.Polar(v67, 170 * pi / 180, 30.62);
            var v86 = fun.Polar(v68, 171 * pi / 180, 30.47);
            var v87 = fun.Polar(v69, 171 * pi / 180, 30.49);
            var v88 = fun.Polar(v51, -90 * pi / 180, 21.64);
            var v89 = fun.Polar(v88, 135 * pi / 180, 5.89);
            var v90 = fun.Polar(v89, pi, 9.52);
            var v91 = fun.Polar(v90, -90 * pi / 180, 3.61);
            var v92 = fun.Polar(v51, -90 * pi / 180, 24);
            var v93 = fun.Polar(v51, -90 * pi / 180, 34.38);
            var v94 = fun.Polar(v93, 202 * pi / 180, 32.07);
            var v95 = fun.Polar(v52, -90 * pi / 180, 40.17);
            var v96 = fun.mirrorpoint(v92, fun.Polar(v51, pi, fun.CalDistance(v51, v52) / 2), fun.Polar(fun.Polar(v51, pi, fun.CalDistance(v51, v52) / 2), -90 * pi / 180, 1));
            var v97 = fun.mirrorpoint(v88, fun.Polar(v51, pi, fun.CalDistance(v51, v52) / 2), fun.Polar(fun.Polar(v51, pi, fun.CalDistance(v51, v52) / 2), -90 * pi / 180, 1));
            var v98 = fun.mirrorpoint(v89, fun.Polar(v51, pi, fun.CalDistance(v51, v52) / 2), fun.Polar(fun.Polar(v51, pi, fun.CalDistance(v51, v52) / 2), -90 * pi / 180, 1));
            var v99 = fun.mirrorpoint(v90, fun.Polar(v51, pi, fun.CalDistance(v51, v52) / 2), fun.Polar(fun.Polar(v51, pi, fun.CalDistance(v51, v52) / 2), -90 * pi / 180, 1));
            var v100 = fun.mirrorpoint(v91, fun.Polar(v51, pi, fun.CalDistance(v51, v52) / 2), fun.Polar(fun.Polar(v51, pi, fun.CalDistance(v51, v52) / 2), -90 * pi / 180, 1));
            var v101 = new Vector2(v98.X, v53.Y);
            var v102 = new Vector2(v99.X, v53.Y);
            var v103 = new Vector2(v90.X, v53.Y);
            var v104 = new Vector2(v89.X, v53.Y);

            Line line1 = new Line(v3, v4);
            line1.Layer = centre;
            line1.Lineweight = Lineweight.W25;
            line1.Linetype = Linetype.DashDot;
            dxf.AddEntity(line1);
            Line line2 = new Line(v1, v2);
            line2.Layer = centre;
            line2.Lineweight = Lineweight.W25;
            line2.Linetype = Linetype.DashDot;
            dxf.AddEntity(line2);
            Line line3 = new Line(v54, v53);
            line3.Layer = centre;
            line3.Lineweight = Lineweight.W25;
            line3.Linetype = Linetype.DashDot;
            dxf.AddEntity(line3);
            var polyline1 = Pus.AddPointsToLwPolyLine(v8, v9);
            polyline1.Vertexes[0].Bulge = Math.Tan((360 * pi / 180 - (fun.CalAngle(v0, v8) - fun.CalAngle(v0, v9))) / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            var polyline2 = Pus.AddPointsToLwPolyLine(v10, v11, v7, v6, v10);
            polyline2.Vertexes[0].Bulge = Math.Tan((360 * pi / 180 - (fun.CalAngle(v0, v10) - fun.CalAngle(v0, v11))) / 4);
            fun.PolyFill(dxf, polyline2, 0.2, contour);


            LwPolyline[] linepoarray3 = new LwPolyline[100];
            var polyline3 = Pus.AddPointsToLwPolyLine(a4, a3, a1, a2, a4, a8, a6);
            polyline3.Vertexes[4].Bulge = Math.Tan(11 * pi / 180 / 4);
            polyline3.Vertexes[5].Bulge = Math.Tan(35 * pi / 180 / 4);
            linepoarray3 = fun.arrayrpolyline(polyline3, nt);
            for (int i = 1; i <= nt; i++)
            {
                fun.PolyFill(dxf, linepoarray3[i], 0.2, contour);
            }
            ;

            LwPolyline[] linepoarray4 = new LwPolyline[100];
            var polyline5 = Pus.AddPointsToLwPolyLine(a2, a7, a5);
            polyline5.Vertexes[0].Bulge = Math.Tan(20 * pi / 180 / 4);
            polyline5.Vertexes[1].Bulge = Math.Tan(90 * pi / 180 / 4);
            linepoarray4 = fun.arrayrpolyline(polyline5, nt);
            for (int i = 1; i <= nt; i++)
            {
                fun.PolyFill(dxf, linepoarray4[i], 0.2, contour);
            }
            ;


            var line14 = new Line(v101, v98);
            fun.drawBline(dxf, line14, 0.2, contour);
            var line15 = new Line(v102, v99);
            fun.drawBline(dxf, line15, 0.2, contour);
            var line16 = new Line(v103, v90);
            fun.drawBline(dxf, line16, 0.2, contour);
            var line17 = new Line(v104, v89);
            fun.drawBline(dxf, line17, 0.2, contour);
            var polyline6 = Pus.AddPointsToLwPolyLine(v55, v56, v57, v58, v59, v60, v55);
            fun.PolyFill(dxf, polyline6, 0.2, contour);
            var polyline7 = Pus.AddPointsToLwPolyLine(v61, v79, v70);
            fun.PolyFill(dxf, polyline7, 0.2, contour);
            var polyline8 = Pus.AddPointsToLwPolyLine(v62, v80, v71);
            fun.PolyFill(dxf, polyline8, 0.2, contour);
            var polyline9 = Pus.AddPointsToLwPolyLine(v63, v81, v72);
            fun.PolyFill(dxf, polyline9, 0.2, contour);
            var polyline10 = Pus.AddPointsToLwPolyLine(v64, v82, v73);
            fun.PolyFill(dxf, polyline10, 0.2, contour);
            var polyline11 = Pus.AddPointsToLwPolyLine(v65, v83, v74);
            fun.PolyFill(dxf, polyline11, 0.2, contour);
            var polyline12 = Pus.AddPointsToLwPolyLine(v66, v84, v75);
            fun.PolyFill(dxf, polyline12, 0.2, contour);
            var polyline13 = Pus.AddPointsToLwPolyLine(v67, v85, v76);
            fun.PolyFill(dxf, polyline13, 0.2, contour);
            var polyline14 = Pus.AddPointsToLwPolyLine(v68, v86, v77);
            fun.PolyFill(dxf, polyline14, 0.2, contour);
            var polyline15 = Pus.AddPointsToLwPolyLine(v69, v87, v78);
            fun.PolyFill(dxf, polyline15, 0.2, contour);
            var polyline16 = Pus.AddPointsToLwPolyLine(v56, v79, v80, v81, v82, v83, v84, v85, v86, v87);
            fun.PolyFill(dxf, polyline16, 0.2, contour);
            var polyline17 = Pus.AddPointsToLwPolyLine(v88, v92, v96, v97, v98, v99, v100, v91, v90, v89, v88);
            fun.PolyFill(dxf, polyline17, 0.2, contour);
            var polyline18 = Pus.AddPointsToLwPolyLine(v95, v94, v93);
            fun.PolyFill(dxf, polyline18, 0.2, contour);











            var hatchpoly1 = Pus.AddPointsToLwPolyLine(v92, v96, v95, v94, v93, v92);
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 20, hline1, harc1, hatching);



            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度



            fun.dimrot1(dxf, fun.Polar(v0, pi, 19.15), fun.Polar(v0, 0, 19.15), 0, 70, 0, height, arrowsize, exline, "DCON=" + D, "", "");
            fun.dimrot1(dxf, v58, v60, 180, offset * 3, 0, height, arrowsize, exline, "CW=" + L, "", "");
            fun.dimrot1(dxf, v56, v59, 90, offset * 3, 0, height, arrowsize, exline, "DC=" + d, "", "");
            fun.jdbz2(dxf, new Line(v57, v56), new Line(v55, v56), offset * 2, height, arrowsize, exline, "KAPR=" + θ + "°", "", "");
            fun.jdbz2(dxf, new Line(v56, v57), new Line(v57, v74), offset * 2, height, arrowsize, exline, "KAPR=" + δ + "°", "", "");



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void Standard6120(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
                                                                           //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            var d = 80.0;//切削直径
            try
            {
                d = Convert.ToDouble(data["dc"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d] not found");
            }
            var D = 22.0;//连接直径
            try
            {
                D = Convert.ToDouble(data["dcon"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[D] not found");
            }
            var d1 = 34.0;//轮毂直径
            try
            {
                d1 = Convert.ToDouble(data["dhub"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[d1] not found");
            }
            var L = 1.0; //切削宽度
            try
            {
                L = Convert.ToDouble(data["cw"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[L] not found");
            }

            var nt = 20.0;//齿数
            try
            {
                nt = Convert.ToDouble(data["nt"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[nt] not found");
            }

            var γ = 360 / nt;
            //坐标
            var v0 = new Vector2(0, 0);
            var v1 = fun.Polar(v0, pi, 61);
            var v2 = fun.Polar(v0, 0, 61);
            var v3 = fun.Polar(v0, 90 * pi / 180, 61);
            var v4 = fun.Polar(v0, -90 * pi / 180, 60);
            var v5 = fun.Polar(v0, -90 * pi / 180, 20);
            var v6 = fun.Polar(v5, pi, 3);
            var v7 = fun.Polar(v5, 0, 3);
            var v8 = new Vector2(v6.X, v0.Y - (Math.Sqrt(Math.Pow(18.5, 2) - Math.Pow(fun.CalDistance(v6, v5), 2))));
            var v9 = new Vector2(v7.X, v0.Y - (Math.Sqrt(Math.Pow(18.5, 2) - Math.Pow(fun.CalDistance(v6, v5), 2))));

            var a1 = fun.Polar(v0, 90 * pi / 180, 46.38);
            var a2 = fun.Polar(v0, 90 * pi / 180, 51.96);
            var a01 = fun.Polar(v0, 90 * pi / 180, 43.75);
            var a0 = fun.Polar(v0, 90 * pi / 180, 53.5);
            var a1p = fun.Polar(v0, (90 - γ) * pi / 180, 43.75);
            var a3 = fun.Polar(a0, fun.CalAngle(a0, a1p), fun.CalDistance(a0, a2));
            var a4 = fun.Polar(a1p, fun.CalAngle(a1p, a0), fun.CalDistance(a01, a1));
            var a5 = fun.Polar(v0, (90 - γ) * pi / 180, 46.38);


            var v27 = fun.Polar(v0, pi, 140);
            var v28 = fun.Polar(v27, pi, 12);
            var v29 = fun.Polar(v27, 0, 10);
            var v30 = fun.Polar(v28, pi, 10);
            var v31 = fun.Polar(v27, 90 * pi / 180, 53.7);
            var v32 = new Vector2(v28.X, v31.Y);
            var v33 = fun.mirrorpoint(v32, v28, v27);
            var v34 = fun.mirrorpoint(v31, v28, v27);
            var v35 = fun.Polar(v27, 90 * pi / 180, 51.29);
            var v36 = fun.Polar(v27, 90 * pi / 180, 48.74);
            var v37 = fun.Polar(v27, 90 * pi / 180, 46.79);
            var v38 = fun.Polar(v27, 90 * pi / 180, 42.59);
            var v39 = fun.Polar(v27, 90 * pi / 180, 40.27);
            var v40 = fun.Polar(v27, 90 * pi / 180, 35.87);
            var v41 = fun.Polar(v27, 90 * pi / 180, 33.46);
            var v42 = fun.Polar(v27, 90 * pi / 180, 24.32);
            var v43 = fun.Polar(v27, 90 * pi / 180, 21.98);
            var v44 = fun.Polar(v27, 90 * pi / 180, 13.33);
            var v45 = fun.Polar(v27, 90 * pi / 180, 10.76);
            var v46 = fun.Polar(v27, -90 * pi / 180, 17.2);
            var v47 = fun.Polar(v27, -90 * pi / 180, 20.97);
            var v48 = fun.Polar(v27, -90 * pi / 180, 29.25);
            var v49 = fun.Polar(v48, pi, 4.6);
            var v50 = fun.Polar(v27, -90 * pi / 180, 47.35);
            var v51 = fun.Inters(v50, fun.Polar(v50, pi, 1), v49, v34);
            var ac1 = fun.Polar(v27, pi, fun.CalDistance(v28, v27) / 2);
            var ac2 = fun.Polar(ac1, -90 * pi / 180, 1);
            var v35p = fun.mirrorpoint(v35, ac1, ac2);
            var v36p = fun.mirrorpoint(v36, ac1, ac2);
            var v37p = fun.mirrorpoint(v37, ac1, ac2);
            var v38p = fun.mirrorpoint(v38, ac1, ac2);
            var v39p = fun.mirrorpoint(v39, ac1, ac2);
            var v40p = fun.mirrorpoint(v40, ac1, ac2);
            var v41p = fun.mirrorpoint(v41, ac1, ac2);
            var v42p = fun.mirrorpoint(v42, ac1, ac2);
            var v43p = fun.mirrorpoint(v43, ac1, ac2);
            var v44p = fun.mirrorpoint(v44, ac1, ac2);
            var v45p = fun.mirrorpoint(v45, ac1, ac2);
            var v46p = fun.mirrorpoint(v46, ac1, ac2);
            var v47p = fun.mirrorpoint(v47, ac1, ac2);
            var v48p = fun.mirrorpoint(v48, ac1, ac2);
            var v49p = fun.mirrorpoint(v49, ac1, ac2);
            var v51p = fun.mirrorpoint(v51, ac1, ac2);

            Line line1 = new Line(v3, v4);
            line1.Layer = centre;
            line1.Lineweight = Lineweight.W25;
            line1.Linetype = Linetype.DashDot;
            dxf.AddEntity(line1);
            Line line2 = new Line(v1, v2);
            line2.Layer = centre;
            line2.Lineweight = Lineweight.W25;
            line2.Linetype = Linetype.DashDot;
            dxf.AddEntity(line2);
            Line line3 = new Line(v29, v30);
            line3.Layer = centre;
            line3.Lineweight = Lineweight.W25;
            line3.Linetype = Linetype.DashDot;
            dxf.AddEntity(line3);


            var polyline1 = Pus.AddPointsToLwPolyLine(fun.Polar(v0, pi, 28.68), fun.Polar(v0, 0, 28.68), fun.Polar(v0, pi, 28.68));
            polyline1.Vertexes[0].Bulge = Math.Tan(180 * pi / 180 / 4);
            polyline1.Vertexes[1].Bulge = Math.Tan(180 * pi / 180 / 4);
            fun.PolyFill(dxf, polyline1, 0.2, contour);
            var polyline2 = Pus.AddPointsToLwPolyLine(v8, v9, v7, v6, v8);
            polyline2.Vertexes[0].Bulge = Math.Tan((360 * pi / 180 - (fun.CalAngle(v0, v8) - fun.CalAngle(v0, v9))) / 4);
            fun.PolyFill(dxf, polyline2, 0.2, contour);

            LwPolyline[] linepoarray3 = new LwPolyline[100];
            var polyline3 = Pus.AddPointsToLwPolyLine(a1, a2, a3, a4, a5);
            polyline3.Vertexes[1].Bulge = Math.Tan(-128 * pi / 180 / 4);
            polyline3.Vertexes[3].Bulge = Math.Tan(106 * pi / 180 / 4);
            linepoarray3 = fun.arrayrpolyline(polyline3, nt);
            for (int i = 1; i <= nt; i++)
            {
                fun.PolyFill(dxf, linepoarray3[i], 0.2, contour);
            }
            ;


            var polyline18 = Pus.AddPointsToLwPolyLine(v31, v32, v33, v34, v31);
            fun.PolyFill(dxf, polyline18, 0.2, contour);

            var line4 = new Line(v35, v35p);
            fun.drawBline(dxf, line4, 0.2, contour);
            var line5 = new Line(v36, v36p);
            fun.drawBline(dxf, line5, 0.2, contour);
            var line6 = new Line(v37, v37p);
            fun.drawBline(dxf, line6, 0.2, contour);
            var line7 = new Line(v38, v38p);
            fun.drawBline(dxf, line7, 0.2, contour);
            var line8 = new Line(v39, v39p);
            fun.drawBline(dxf, line8, 0.2, contour);
            var line9 = new Line(v40, v40p);
            fun.drawBline(dxf, line9, 0.2, contour);
            var line10 = new Line(v41, v41p);
            fun.drawBline(dxf, line10, 0.2, contour);
            var line11 = new Line(v42, v42p);
            fun.drawBline(dxf, line11, 0.2, contour);
            var line12 = new Line(v43, v43p);
            fun.drawBline(dxf, line12, 0.2, contour);
            var line13 = new Line(v44, v44p);
            fun.drawBline(dxf, line13, 0.2, contour);
            var line14 = new Line(v45, v45p);



            if (d >= 8 && d <= 63)
            {
                fun.drawBline(dxf, line14, 0.2, contour);
                var line15 = new Line(v46, v46p);
                fun.drawBline(dxf, line15, 0.2, contour);
                var line16 = new Line(v51, v51p);
                fun.drawBline(dxf, line16, 0.2, contour);
                var line17 = new Line(v47, v47p);
                fun.drawBline(dxf, line17, 0.2, contour);


                var polyline19 = Pus.AddPointsToLwPolyLine(v48p, v49p, v33, v34, v49, v48);
                fun.PolyFill(dxf, polyline19, 0.2, contour);

                var hatchpoly1 = Pus.AddPointsToLwPolyLine(v47, v47p, v48p, v49p, v51p, v51, v49, v48, v47);
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 20, hline1, harc1, hatching);
            }


            if (d >= 80 && d <= 125)
            {
                var v52 = new Vector2(v51.X - fun.CalDistance(v51, v51p) / 4, v27.Y);
                var v53 = fun.mirrorpoint(v52, ac1, ac2);
                var v54 = fun.Inters(v51, v52, v46, fun.Polar(v46, pi, 1));
                var v55 = fun.mirrorpoint(v54, ac1, ac2);

                var polyline19 = Pus.AddPointsToLwPolyLine(v52, v51, v51p, v53);
                fun.PolyFill(dxf, polyline19, 0.2, contour);


                var line15 = new Line(v54, v55);
                fun.drawBline(dxf, line15, 0.2, contour);


                var hatchpoly1 = Pus.AddPointsToLwPolyLine(v51, v51p, v55, v54, v51);
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 20, hline1, harc1, hatching);



            }


            var height = 2.5;//字体高度
            var offset = 10;//偏移量
            var arrowsize = 1;//箭头大小
            var exline = 1;//延伸线长度



            fun.dimrot1(dxf, fun.Polar(v0, pi, 18.5), fun.Polar(v0, 0, 18.5), 0, 60, 0, height, arrowsize, exline, "DCON=" + D, "", "");
            fun.dimrot1(dxf, fun.Polar(v0, pi, 28.68), fun.Polar(v0, 0, 28.68), 0, 75, 0, height, arrowsize, exline, "DHUB=" + d1, "", "");
            fun.dimrot1(dxf, v33, v34, 180, offset * 3, 0, height, arrowsize, exline, "CW=" + L, "", "");
            fun.dimrot1(dxf, v32, v33, 90, offset * 3, 0, height, arrowsize, exline, "DC=" + d, "", "");


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void _7to24handle(DxfDocument dxf, Vector2 hp1, Vector2 hp2, double D1, double d1, double z, double L, double l1, double p, double zdh)//msyz莫氏锥柄号，bingxing柄型 1为1型 2为2型，d0为切削直径
        {
            //DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //参数
            double pi = Math.PI;
            double a = Math.Atan(7.0 / 48);
            //string path = Convert.ToString(data["path"]);

            if (zdh == 30)
            {
                D1 = 31.75;
                z = 0.4;
                L = 68.4;
                l1 = 48.4;
                d1 = 17.4;
                p = 3;
            }

            if (zdh == 40)
            {
                D1 = 44.45;
                z = 0.4;
                L = 93.4;
                l1 = 65.4;
                d1 = 25.3;
                p = 5;
            }

            if (zdh == 45)
            {
                D1 = 57.15;
                z = 0.4;
                L = 106.8;
                l1 = 82.8;
                d1 = 32.4;
                p = 6;
            }

            if (zdh == 50)
            {
                D1 = 69.85;
                z = 0.4;
                L = 126.8;
                l1 = 101.8;
                d1 = 39.6;
                p = 8;
            }

            if (zdh == 55)
            {
                D1 = 88.9;
                z = 0.4;
                L = 164.8;
                l1 = 126.8;
                d1 = 50.4;
                p = 9;
            }

            if (zdh == 60)
            {
                D1 = 107.95;
                z = 0.4;
                L = 206.8;
                l1 = 161.8;
                d1 = 60.2;
                p = 10;
            }

            //点
            //Vector2 v4=fun.Polar(hp1,)


        }
    }
}
